Guide · Scope creep
How to keep Claude Code, Cursor and Codex inside the task
You ask an AI agent to fix the profile page. It also "tidies" the billing module and renames a public API field. This is scope creep, and it is where most AI regressions come from.
The fix: make the scope explicit, then check it
Telling the agent "only touch the profile page" in a prompt helps, but nothing verifies it. The reliable pattern has two halves: declare which files the task may change, and compare what actually changed against that list, including anything the agent already committed.
npx stet-cli init
stet scope set "Fix profile page" --allow "src/profile/**,tests/profile/**"
# ...the agent works...
stet guard
Guarding 3 changed files · task: Fix profile page
✓ src/profile/Profile.tsx
✓ tests/profile/profile.test.ts
✗ src/billing/invoice.ts out of scope
✗ 1 file outside scope or protected. Revert, or widen the scope on purpose.
Protected paths (migrations, CI config, secrets handling) can be flagged on every task via .stet/config.json. Uncommitted work from an earlier task is carried and ignored unless the agent changes it again.
Setup per tool
| Tool | How the agent learns the scope |
|---|---|
| Claude Code | MCP: claude mcp add stet -- npx -y stet-cli mcp. The agent can read the scope (stet_scope) and run stet_guard, but cannot change the scope. |
| Cursor | MCP: add stet to .cursor/mcp.json with command npx -y stet-cli mcp. |
| Codex, GitHub Copilot, Windsurf, Gemini CLI | Read AGENTS.md, which Stet updates with the current task and allowed files. |
| ChatGPT, Claude.ai, Gemini chat | stet context --files "src/profile/**" copies the rules, scope and code to paste in. |
Make it impossible to skip
stet hook installadds a pre-commit hook that blocks commits staging out-of-scope or protected files.- In CI:
npx -y stet-cli guard --base origin/mainfails a pull request that strays. stet scope done --commitcloses a task: guard and check, then commit only the task's files.
FAQ
What if the task really needs another file?
Widen the scope on purpose: set it again with the extra glob. The point is that a human decides, not the agent.
Does guard slow anything down?
No. It reads git and runs in well under a second.
Scope your next AI task
npx stet-cli init · Setup guide · Why rules files aren't enough →