You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+78-11Lines changed: 78 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,6 +245,62 @@ How the maintainer works day-to-day. Documents intent and handoff conventions fo
245
245
-**Explicit confirmation required** for: merging a PR, and anything in the destructive-command list in `AGENTS.md` (deletions, force-pushes, infrastructure changes).
246
246
- Agents should run unit tests themselves — no need to ask first.
247
247
248
+
### Maintainer-directed issue swarm
249
+
250
+
When the maintainer asks the parent agent to distribute a backlog across
251
+
subagents, use this stricter issue-by-issue flow:
252
+
253
+
1.**The issue is the unit of authorization.** Never start implementation
254
+
without an existing issue. One worker owns exactly one issue at a time in
255
+
one isolated worktree and short-lived branch. Do not mix opportunistic fixes
256
+
from another issue into its diff. If the maintainer names a required first
257
+
wave, schedule those issues before optional work.
258
+
2.**Start from current `origin/main`.** Fetch before creating a worktree and
259
+
record the exact base SHA. When `main` advances, especially after a sibling
260
+
or release merge, preserve the complete local diff with
261
+
`git stash push --include-untracked -m <unique-issue-and-base>`, record and
262
+
verify the resulting stash commit OID, update the uncommitted branch only
263
+
with `git merge --ff-only origin/main`, and restore with
264
+
`git stash apply <OID>`. Never pop or drop the backup until the moved diff is
265
+
validated; never use `reset --hard`, forced checkout, or `clean`. Stop on a
266
+
non-fast-forward or conflict. Prove that merged commits occur exactly once,
267
+
re-review overlapping files, and rerun the affected tests after the move.
268
+
3.**Review before spending CI.** Risky or cross-cutting work first reports a
269
+
design and test plan, then a production-diff checkpoint. Every
270
+
implementation, regardless of risk, reports the complete diff after local
271
+
verification and passes the independent review gate below before commit,
272
+
push, or PR. The parent/orchestrator requests polishing before expensive
273
+
macOS or UI runners test the candidate.
274
+
4.**Keep concurrent Xcode work isolated.** Give every issue a unique
275
+
`-derivedDataPath` under `/private/tmp`; never share DerivedData between
276
+
workers. Record the exact macOS, Xcode, SDK version, commands, test counts,
277
+
and result-bundle path. A code failure gets diagnosed and reviewed before a
278
+
bounded retry; do not hide a failure with repeated blind reruns.
279
+
5.**Verification is evidence, not a summary.** Always run `git diff --check`.
280
+
Run every applicable targeted check and state each non-applicable check with
281
+
a reason: SwiftLint for Swift/code changes, targeted tests for behavioral
282
+
changes, and the existing full pre-PR build for code PRs. Add broader suites,
283
+
UI tests, security/race tests, or renderer checks when the issue requires
284
+
them. Report unrelated failures separately, but never call a PR merge-ready
285
+
until every required GitHub check is green.
286
+
6.**Publish in dependency order.** Only after the parent review clears may the
287
+
worker make a Conventional Commit. The parent then performs a final commit
288
+
review, pushes, opens the issue-linked PR, states the merge order, and watches
289
+
CI. A worker subagent never merges its own PR.
290
+
7.**Merge authorization is narrow.** By default only the maintainer merges.
291
+
If the maintainer explicitly authorizes the parent/orchestrator to merge
292
+
working PRs, the authorization must identify the exact PR numbers and
293
+
current head SHAs; a batch is an immutable enumeration of those exact
294
+
`(PR number, head SHA)` pairs. Revalidate them immediately before merge.
295
+
Only non-release PRs that remain mergeable, have a clean review gate, and
296
+
have every required check green may merge. Red or pending PRs are never
297
+
merged. Release actions require separate, exact authorization covering each
298
+
requested operation: Release Please PR merge; tag create, update, delete,
299
+
or push; and release-workflow edit, dispatch, rerun, or cancellation. After
300
+
any authorized Release Please PR merge, regardless of actor, treat the
301
+
resulting release commit as the new mandatory base for all active issue
302
+
branches.
303
+
248
304
### Independent review gate
249
305
250
306
Every implementation must pass an independent, fresh-context review before
@@ -254,8 +310,13 @@ Green CI remains necessary, but it does not replace that review.
254
310
255
311
1.**Review the local candidate diff before push.** Once implementation and
256
312
regression tests are stable, review the complete local diff against its
257
-
intended base (`main...HEAD`, plus any staged or unstaged changes). Run at
258
-
least three read-only reviewer subagents with distinct lenses: (a)
313
+
intended base (`main...HEAD`, plus any staged or unstaged changes). Keep the
314
+
original worktree path as the single mutable copy, include
315
+
`git status --short`, and represent every untracked file explicitly with a
316
+
manifest plus a `git diff --no-index /dev/null <file>` patch (or an
317
+
equivalent content-complete artifact). Review and fix workers must use that
318
+
same worktree until commit. Run at least three read-only reviewer subagents
319
+
with distinct lenses: (a)
259
320
correctness and architecture, (b) concurrency, security, and lifecycle
260
321
races, and (c) tests, UX, localization, and OS compatibility. Reviewers
261
322
must read the issue acceptance criteria and must not edit files.
@@ -268,9 +329,11 @@ Green CI remains necessary, but it does not replace that review.
268
329
All confirmed P0, P1, and P2 findings must be resolved before merge. Record
269
330
low-risk coverage gaps or P3 findings in the PR or a follow-up issue when
270
331
they are intentionally deferred.
271
-
4.**Fix on the same local branch.** Add follow-up commits; never amend or
272
-
force-push. Repeat the independent review/fix loop until reviewers return
273
-
no unresolved P0-P2 findings, then rerun the relevant local checks.
332
+
4.**Fix on the same local branch.** In the maintainer-directed flow, keep the
333
+
candidate uncommitted until review clears. If the candidate was already
334
+
committed under a different flow, add follow-up commits; never amend or
335
+
force-push. Repeat the independent review/fix loop until reviewers return no
336
+
unresolved P0-P2 findings, then rerun the relevant local checks.
274
337
5.**Push and open the PR only after review clears.** Summarize reviewer
275
338
angles, findings, dispositions, and local verification in the PR body.
276
339
Run the full required CI once the PR exists. An agent with explicit merge
@@ -284,16 +347,20 @@ Green CI remains necessary, but it does not replace that review.
284
347
285
348
### Milestone orchestration with subagents
286
349
287
-
For a milestone with multiple issues, the maintainer (or a parent agent) orchestrates implementation across subagents instead of doing all the work in one session. Used for parallelizable issues, large features, or when strict adversarial review is wanted. The full loop runs inside the agent; the human only merges at the end.
350
+
For a milestone with multiple issues, the maintainer (or a parent agent) orchestrates implementation across subagents instead of doing all the work in one session. Used for parallelizable issues, large features, or when strict adversarial review is wanted. The full loop runs inside the agent; the maintainer merges by default, or may explicitly authorize the parent/orchestrator to merge under the narrow gate above.
288
351
289
352
Flow:
290
353
1.**Scope first.** Read every issue in the milestone end-to-end, identify shared files, and note dependencies (`blocked-by`, or an explicit "depends on #X" in the body). Order implementation and merge accordingly.
291
-
2.**One issue = one worker = one candidate branch.** Delegate each issue to a worker subagent in an isolated worktree (`worktree: true`). Each worker creates its own local branch, commits the candidate, runs local verification, and reports it for review without pushing or opening a PR. Pass each worker explicit permissions in the task and an `acceptance` contract with `verify` commands and `stopRules` (notably: never push, never open a PR, never merge, never force-push, never amend before review clears).
292
-
3.**Respect cross-issue boundaries.** Tell each worker exactly which files/branches it may touch so sibling PRs stay mergeable (e.g. add a dedicated accumulator field per branch instead of repurposing a shared one). When an issue depends on siblings not yet merged, the dependent worker merges those sibling branches into its own branch and documents it in the PR body — GitHub auto-shrinks the diff once the siblings land.
354
+
2.**One issue = one worker = one candidate branch.** Delegate each issue to a worker subagent in an isolated worktree (`worktree: true`). Each worker creates its own local branch, implements the candidate, runs local verification, and reports the complete working diff for review without committing, pushing, or opening a PR. Pass each worker explicit permissions in the task and an `acceptance` contract with `verify` commands and `stopRules` (notably: never commit before review clears, never push, never open a PR, never merge, never force-push, never amend).
355
+
3.**Respect cross-issue boundaries.** Tell each worker exactly which files/branches it may touch so sibling PRs stay mergeable (e.g. add a dedicated accumulator field per branch instead of repurposing a shared one). When an issue depends on siblings not yet merged, wait for them to land or have the parent create a separately reviewed integration base with a recorded SHA and exactly-once proof. Workers do not merge or cherry-pick sibling branches into an uncommitted candidate.
293
356
4.**Strict review from fresh context before push.** Run fresh-context `reviewer` subagents with distinct angles against each complete local candidate diff. Reviewers are read-only — they must not edit.
294
-
5.**Fix before opening the PR.** Synthesize reviewer findings and hand them to a fix-worker that checks out the **existing local candidate branch** and adds a follow-up commit. Never amend, force-push, or open a new branch for fixes. Repeat the review/fix loop until reviewers return a clean verdict (typically ~2 rounds).
295
-
6.**Publish and verify after review.** Only now push each reviewed branch and open its PR. Confirm every PR is `MERGEABLE` and **fully green** — every required CI check passing, no exceptions. Pending checks must be explicitly noted. There is no "red but mergeable" state: branch protection blocks the merge button on any failing check, so a red PR is not ready regardless of why it failed. State the merge order.
296
-
7.**Never merge.** The agent opens and reviews PRs; only the human merges them.
357
+
5.**Fix before opening the PR.** Synthesize reviewer findings and hand them to a fix-worker that uses the **existing local candidate branch** and working diff. Keep fixes uncommitted until the review gate is clean. Never amend, force-push, or open a new branch for fixes. Repeat the review/fix loop until reviewers return a clean verdict (typically ~2 rounds), then create the Conventional Commit.
358
+
6.**Publish and verify after review.** Only now does the parent/orchestrator push each reviewed branch and open its PR. Confirm every PR is `MERGEABLE` and **fully green** — every required CI check passing, no exceptions. Pending checks must be explicitly noted. There is no "red but mergeable" state: branch protection blocks the merge button on any failing check, so a red PR is not ready regardless of why it failed. State the merge order.
359
+
7.**Workers never publish or merge.** After review clears, the
360
+
parent/orchestrator opens and reports the PR. It merges only when the
361
+
maintainer has explicitly delegated that authority and all review,
362
+
dependency-order, and green-CI requirements above are satisfied; otherwise
363
+
the maintainer merges.
297
364
298
365
Operational notes:
299
366
- Worktree isolation requires a clean main tree — remove stray artifacts (e.g. a `reviews/` folder written by reviewers) before launching new worktree runs.
0 commit comments