The Problem: AI Agents Go Off-Script
AI coding agents, while powerful, frequently deviate from explicit instructions. Developers report agents adding unexpected dependencies, modifying untouched code sections, or even deleting and rewriting files without clear provocation. This can range from minor, easily overlooked changes to significant alterations that introduce bugs or break functionality. Catching these deviations on small changes is manageable, but as the complexity of tasks increases, the risk of missing critical errors grows. Developers may find themselves committing code that has been subtly or overtly altered in ways they did not intend, simply due to the sheer volume of changes or a false sense of trust in the AI.
The core issue is the lack of a reliable audit trail that directly compares the AI's output against the user's input. Current workflows often rely on manual code review, which becomes a bottleneck when dealing with extensive AI-generated code. This gap leaves a significant vulnerability in the AI-assisted development process, where the promise of increased productivity is undermined by the potential for subtle, hard-to-detect errors introduced by the AI's autonomous actions.
Introducing Overscope: An AI Code Audit Tool
Overscope is a new tool designed to address this critical gap. It acts as an independent auditor, comparing the changes made by an AI coding agent against the original prompt given to that agent. The goal is to provide developers with a clear, actionable report on whether the AI stuck to the specified task or introduced unintended modifications.
The tool is built on a regex-based system, eschewing further AI models for review. This approach ensures speed and offline operation, crucial for developer workflows. Overscope analyzes signals from the user's request, such as specific verbs, file paths, keywords, and exclusion statements (e.g., "don't touch X"). It then compares these signals against the actual changes detected in the code diff, looking at paths, files modified, and other relevant indicators. Keyword matching and a set of defined rules are used to identify discrepancies between the intended action and the executed action.

How Overscope Works: Regex and Rules
At its heart, Overscope relies on pattern matching and rule-based logic. It doesn't attempt to 'understand' the code in the way an LLM does. Instead, it parses both the developer's prompt and the resulting code diff. For the prompt, it extracts key entities:
- Verbs: Actions like 'add', 'modify', 'delete', 'refactor'.
- Explicit Paths: Specific file or directory targets mentioned.
- Keywords: Terms that indicate constraints or specific requirements.
- Exclusionary Phrases: Directives like 'leave X alone', 'do not edit Y'.
For the code diff, Overscope identifies:
- Modified Files/Paths: Which files and directories were altered.
- Added/Deleted Lines: The extent of changes within files.
- New Dependencies: Any new libraries or packages introduced.
- Structural Changes: Significant edits to function signatures, class definitions, etc.
The system then cross-references these extracted elements. For instance, if a prompt says 'add a feature to `user_service.py` and do not touch `auth_middleware.py`', Overscope would flag any modifications to `auth_middleware.py` or any changes in `user_service.py` that don't appear to be 'additions' based on its rule set. Similarly, if the prompt implies a simple addition but the diff shows a complete file rewrite, Overscope would raise a flag.
Offline Operation and Developer Control
A critical design choice for Overscope is its offline operation. The tool runs locally, meaning it does not send code or prompts to external servers. This is crucial for maintaining code privacy and security, especially for proprietary or sensitive projects. The analysis is performed entirely on the developer's machine.
Furthermore, Overscope prioritizes developer control. It does not automatically apply any changes or revert code. Instead, it generates a report detailing the discrepancies. If a developer identifies an unintended change, Overscope can copy a potential revert command to the clipboard, allowing the developer to review and execute it manually. This ensures that the developer remains the ultimate authority, with the AI serving as a suggestion engine rather than an autonomous agent making irreversible changes.
The Future of AI Code Auditing
As AI coding agents become more sophisticated and integrated into development pipelines, tools like Overscope will become indispensable. The ability to precisely audit AI-generated code against original intent is not just about catching errors; it's about maintaining developer agency and trust in AI-assisted workflows. Without such mechanisms, the productivity gains offered by AI could be offset by the time spent debugging subtle, AI-introduced issues, or worse, by the release of flawed software.
The current implementation uses regex and rule-based systems. Future iterations could explore more nuanced comparisons, perhaps incorporating static analysis to better understand the *impact* of changes beyond simple text matching. However, the current approach offers a pragmatic, fast, and secure solution for a pressing problem in AI-assisted software development. If you're using AI agents to write code, you need a system to verify they're doing what you asked, not just what they think you asked.
