[FORGE-106] docs(skills,templates): agent-discipline rules — source of truth + precedence + worktree-guard inverse (P2.5-T14)#190
Merged
Conversation
…f truth + precedence + worktree-guard inverse (P2.5-T14)
Bundle three rules that emerged from real dogfooding failures into a single
docs PR shipped to every adopter via `npm install @firatcand/forge`:
1. §Source of truth + §Precedence rules — authority-by-field matrix mirroring
templates/worker-prompt.template.md, with strict precedence as tiebreaker.
Lands in both forge's own CLAUDE.md and templates/CLAUDE.project.template.md.
Rule: AI agents query the tracker directly for status; never grep phases.yaml.
2. §Skill ↔ verb contract — skills own UX, verbs own state machine. Brief
pointer to spec/SPEC.md + spec/ORCHESTRATOR.md for the full story.
3. §Ephemeral ADR workflow (v0.5) — renamed existing "Decision records" section
to keep terminology consistent with /update-spec design.
Additional changes:
- skills/_shared/worktree-guard.md: append §Inverse rule covering the symmetric
trap (observational cd from a main session polluting cwd for every later
command). Includes wrong-vs-right cd vs git -C example pair.
- skills/pickup-task/SKILL.md: step 1 rewritten to mandate tracker-first lookup
+ explicit warning against grepping phases.yaml status fields.
- skills/{forge-orchestrate,sync-status}/SKILL.md: top one-liner cross-reference.
- CONTRIBUTING.md: manual grep recipe (forbidden orchestrate verbs) added to
Local validation section (in lieu of optional husky hook — no husky in repo).
Decisions: Source-of-truth section landed in both forge CLAUDE.md and template
per user answer; precedence rendered as authority-by-field matrix with
strict-precedence one-line tiebreaker per user answer.
Side effect: filed FORGE-136 for ensure-worktree stale CRITICAL.md hydration
bug discovered while preparing this commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… match SPEC authority-by-field model Two high-confidence findings (10/10) from Codex review of PR #190: 1. Matrix consistency. The phases.yaml row diverged from SPEC.md:42 and templates/worker-prompt.template.md:29 — both use "Local execution snapshot (derived from tracker; do not hand-edit)" while this PR originally said "Dependency graph (cached snapshot)", implying phases.yaml IS authoritative for the graph. Realigned to SPEC's exact wording. Extended the stale-fields warning to cover dependency fields, not just status, since phases.yaml caches the entire derived view. 2. Precedence tiebreaker. SPEC.md:16 and SPEC.md:36 explicitly say the 6-level precedence chain was REPLACED by authority-by-field in the 2026-05-17 PM amendment — not kept as a tiebreaker. This PR originally re-introduced the chain as a tiebreaker line. Removed the tiebreaker and replaced it with prose that mirrors SPEC's "ask whose field is this" framing, explicitly noting that the 6-level ordering used pre-2026-05-17 was replaced by the matrix. 3. Bonus: pickup-task skill description still said "Linear (or local phases.yaml)" — stale wording predating the new rule. Updated to name the tracker types directly. Step 1 prose also extended to forbid grepping phases.yaml for dependencies (not just status), matching the corrected matrix. Decision: Codex Finding 8 (broken §Skill ↔ verb contract reference in SPEC.md) was a false positive — the section exists at SPEC.md:929. Codex's file read was incomplete. Not addressing. Other findings (3 inverse-rule wording, 4 step-1 mechanical, 5 grep recipe false positives, 6 byte-equality, 7 markdown rendering) all came back clean or as nits — no action needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bundles three durable "agent-discipline" rules into a single docs PR that ships to every adopter via
npm install @firatcand/forge. All three emerged from real dogfooding failures observed during this single session.What changed (7 files, +87/-4)
CLAUDE.md+templates/CLAUDE.project.template.md— added three sections (identical text in both files):phases.yamlowns the cached dependency graph (status fields are stale), Tracker owns live execution truth, source code owns implementation. Explicit rule for AI agents: query the tracker directly for any status question; never grepphases.yamlforstatus/completedAt. Strict precedence (user > SPEC > PRD > phases.yaml > tracker > attempts) included as a one-line tiebreaker.spec/SPEC.md+spec/ORCHESTRATOR.mdfor the full state-machine ownership story./update-specskill.skills/_shared/worktree-guard.md— appended §Inverse rule: inspecting a worktree from outside. The existing guard refuses mutation from main; the symmetric trap is observationalcd .forge/worktrees/<ID> && git logpoisoning cwd for every subsequent command in the session. Rule: usegit -C <path> <cmd>for read-only inspection from any session not pinned to a worktree by/pickup-task. Includes a wrong-vs-rightcdvsgit -Cexample pair.skills/pickup-task/SKILL.md— rewrote step 1 to mandate tracker-first lookup with an explicit warning thatphases.yamlstatus fields are stale and must NOT be grep'd; added a top-of-file cross-reference to §Source of truth.skills/forge-orchestrate/SKILL.md+skills/sync-status/SKILL.md— top-of-file one-liner: "Status queries always hit the tracker.plans/phases.yamlis a stale cache."CONTRIBUTING.md— added a manualgit greprecipe to the Local validation section as a guard against removed orchestrate verbs reappearing (no husky in repo, so AC's optional pre-commit hook was rendered as a contributor-facing check).Why now
Both class-of-bugs the new rules prevent were hit during this single session:
plans/phases.yamlstatus:fields instead of querying Linear — exactly the failure §Source of truth now forbids.cd .forge/worktrees/FORGE-88 && git logpoisoned cwd of a main-pinned session, causing every following command to resolve against the wrong worktree until caught — exactly the failure §Inverse rule now forbids.The 6-level precedence contract (original AC) was already in
templates/worker-prompt.template.md's "Authority by field" matrix; this PR makes the supervisor-side documentation (CLAUDE.md, skills) match.Side effect: filed FORGE-136
Discovered mid-implementation:
forge orchestrate ensure-worktreehydrated a staleCRITICAL.mdthat, if committed, would have silently reverted FORGE-88'ssrc/harnesses/**codex-auto-review glob. Filed as P1 follow-up to FORGE-98 with repro details and acceptance criteria.Test plan
npm run typecheck— cleannpm test— 1276 passed / 0 failed / 15 skippednpm run build— dual ESM+CJS bundles emit cleanlynode dist/bin/forge.cjs --version— smoke OKgitleaks detect— no leaksLinked
Closes FORGE-106.
Related: FORGE-136 (filed mid-implementation).
🤖 Generated with Claude Code