Pattern
safety
workflow

When to Stop the Agent

Recognizing when to intervene manually and take back control from AI assistance.

The Intervention Decision

AI assistance works well until it doesn't. Knowing when to take over is a critical skill.

Red Flags: Stop Immediately

1. Modifying Wrong Files

If AI starts changing files you didn't mention:

STOP. "I only asked you to modify auth.ts. Why are you
changing database.ts and user.ts?"

2. Installing Unexpected Dependencies

STOP. "You're adding three new packages. Let's discuss
whether we need these before installing."

3. Destructive Operations

STOP. "You're about to delete files. Let me review
exactly what will be removed first."

4. Circular Fixes

After 3 fix attempts that create new errors:

STOP. "We're going in circles. Let me think about
the root cause before we try again."

5. Security Concerns

STOP. "This code is handling passwords. Let me review
the security implications manually."

Yellow Flags: Proceed with Caution

1. Unfamiliar Patterns

AI suggests code using patterns you don't recognize:

PAUSE. "Before I accept this, explain:
1. What pattern is this?
2. Why use it here?
3. What are the tradeoffs?"

2. Complex Changes

The diff is large or touches many files:

PAUSE. "This is a big change. Let's break it into
smaller pieces I can review individually."

3. Performance-Critical Code

PAUSE. "This is a hot path. Let's add benchmarks
before and after to verify performance."

4. External API Changes

PAUSE. "This changes our public API. Let's document
the change and consider versioning."

When to Take Over Completely

Domain-Specific Logic

AI doesn't understand your business:

markdown
AI: "Here's the pricing calculation..."

YOU: Actually, let me write this. There are business
rules that aren't documented anywhere. I'll write
the core logic, then you can help with tests.

Security-Critical Code

markdown
AI: "Here's the authentication flow..."

YOU: I need to write the auth code myself. You can
review it when I'm done.

Performance-Critical Code

markdown
AI: "Here's the database query..."

YOU: This runs on every request. I'll write it
with specific optimizations in mind.

Debugging Complex State

markdown
AI: "The error is because..."

YOU: I need to understand this myself. Let me step
through with a debugger.

Intervention Patterns

The Scope Lock

When AI drifts from the task:

markdown
LOCK SCOPE:
- Only modify: src/components/Button.tsx
- Do not touch: Any other file
- Do not suggest: Additional improvements
- When done: Stop and ask for review

The Checkpoint

Force verification points:

markdown
After each of these steps, STOP and wait for me:
1. Add the type definitions
2. Implement the function
3. Add the tests
4. Update documentation

The Rollback Trigger

Set clear rollback conditions:

markdown
If any of these happen, STOP:
- Tests fail
- Lint errors appear
- The app won't start
- You're unsure about something

I'll decide whether to continue or rollback.

Recovery Actions

After Stopping

  1. Assess the damage

    bash
    git status
    git diff
    
  2. Decide: Keep or rollback

    • Keep partial work if it's useful
    • Rollback if it's causing problems
  3. Document what went wrong

    • Update AGENTS.md with new constraints
    • Add to your personal lessons learned

Quick Rollback

bash
# Discard all changes
git checkout -- .

# Or rollback to last commit
git reset --hard HEAD

Selective Rollback

bash
# Keep some changes, discard others
git checkout -- path/to/bad/file.ts

Training Your Instincts

Questions to ask periodically:

  • Am I still in control of this change?
  • Do I understand what the AI is doing?
  • Could I explain this code in a review?
  • Am I learning or just copying?

The 10-Second Rule

Before accepting any AI output, take 10 seconds to:

  1. Read the changes
  2. Understand the approach
  3. Consider edge cases
  4. Check for red flags

If you can't do this in 10 seconds, slow down.

Verification

You're intervening appropriately if:

  • You catch problems before they're committed
  • You can explain every change in your PRs
  • You learn from AI suggestions, not just copy them
  • You maintain control of your codebase