a-handoff-is-not-a-sta…
AgentAt the end of each session your agent writes a paragraph that says what it did. The next session still spends its first half hour…
A repository has a project-wide scope contract, and each task adds its own. The checker currently reads whichever file it finds first. Write the merge rule for every field so that the result is mechanical, reviewable and never looser than either input.
Claude Code
$ npx -y skills add rohitg00/ai-engineering-from-scratch --agent claude-code
Cursor
Cursor also loads subagents from .claude/agents, so copy this file there to use it in Cursor.
id: merge-two-scope-contracts title: Two scope contracts apply to one diff, define the merge card: agents kind: design level: 4 roles: [agentic-ai-engineer, ai-evaluation-reliability-engineer] rounds: [system-design, design-review] tags: [scope-contract, least-privilege, merge-semantics, egress, time-budget] minutes: 15 lessons: [phases/14-agent-engineering/36-scope-contracts] manuals: [] practice: [] cheatsheet: [agent-workbench-ops] related: [agents/a-login-fix-touched-five-files, agents/safe-actions-harmful-trajectory] updated: 2026-11-03
A repository has a project-wide scope contract, and each task adds its own. The checker currently reads whichever file it finds first. Write the merge rule for every field so that the result is mechanical, reviewable and never looser than either input.
Merge by least privilege. Intersect the allowed globs, so that a path must be permitted by both contracts, and union the forbidden globs, so that either contract can prohibit a path. Take the smaller time budget, accumulate the approvals required, and treat the egress allowlist with three states: unset defers to the other side, two lists intersect, and an empty list stays deny-all. Write the rule into the contract schema so that the checker and the reviewer apply the same merge.
| Field | Merge | Reason | |---|---|---| | `allowed_files` | Intersection | Both contracts must permit the write | | `forbidden_files` | Union | Either contract can prohibit | | `time_budget_minutes` | Minimum | The stricter clock wins | | `approvals_required` | Union | A sign-off demanded by either is demanded by the merge | | `network_egress` | See below | Three states, with deny-all absorbing | | `acceptance_criteria` | Union | Every proof demanded by either must run | | `rollback_plan` | Both kept | The operator needs each runbook |
`network_egress` has three states. `None` means no enforcement from this contract. `[]` means deny all. A list means an allowlist. Under merge, `None` defers to the other side, two lists intersect, and `[]` on either side yields `[]`. That last point matters: a task contract cannot open the network when the project contract closed it.
A merge rule that lives in the checker's code is invisible to the reviewer who approves the contracts. A rule that lives in the schema is read by the checker, by the reviewer and by the agent. The lesson's framing is that the contract turns "stay in scope" from a wish into a check, and a merge that is not written down is a wish again.
Off-scope writes to documentation are usually a warning, and writes under scripts, migrations or production config are always a block. Under merge, take the stricter severity for a path that both contracts classify. Keep the per-task violation budget, so that small slips surface as warnings and only a budget overrun blocks.
The feature list bounds the project, and the contract bounds the task. The merged `allowed_files` must sit inside what the active feature touches. If the task contract asks for a path the feature does not cover, the startup check fails before any write.
The [scope contracts lesson](../../../phases/14-agent-engineering/36-scope-contracts/) gives the least-privilege merge and the three-state egress rule.
At the end of each session your agent writes a paragraph that says what it did. The next session still spends its first half hour…
Read this part of the harness loop. A subscriber on `before_tool_call` raises `HookAbort` on the second step of a three-step…
The task given to the agent was to fix one login bug. The diff changes the login route, an email helper, the database driver, the…
The product team wants a single maximum number of turns that applies to every run of your agent. The agent handles one-line…
Read this run method from the toy agent loop. A caller shows the returned string to the user as the answer. What is wrong with…
A long coding session has used most of its context window. The runtime offers to summarize the older turns and keep going. Your…
Reviews the repository's shared Claude Code configuration (.claude/settings.json, CLAUDE.md, .claude/rules/, .mcp.json and the…
Generate comprehensive API documentation by scanning Express route files.
Advisor to a busy principal. Optimizes for the user's time, attention, and decision quality. One of the starter-kit council…