Skip to content

[FORGE-106] docs(skills,templates): agent-discipline rules — source of truth + precedence + worktree-guard inverse (P2.5-T14)#190

Merged
firatcand merged 2 commits into
mainfrom
feat/FORGE-106
May 18, 2026
Merged

[FORGE-106] docs(skills,templates): agent-discipline rules — source of truth + precedence + worktree-guard inverse (P2.5-T14)#190
firatcand merged 2 commits into
mainfrom
feat/FORGE-106

Conversation

@firatcand
Copy link
Copy Markdown
Owner

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):
    • §Source of truth — authority-by-field matrix: SPEC owns architecture, PRD owns product behavior, phases.yaml owns 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 grep phases.yaml for status/completedAt. Strict precedence (user > SPEC > PRD > phases.yaml > tracker > attempts) included as a one-line tiebreaker.
    • §Skill ↔ verb contract — skills own UX, verbs own state machine. Brief pointer to spec/SPEC.md + spec/ORCHESTRATOR.md for the full state-machine ownership story.
    • §Ephemeral ADR workflow (v0.5 — not active in v0.4) — renamed forge's existing "Decision records" section for terminology consistency with the planned /update-spec skill.
  • skills/_shared/worktree-guard.md — appended §Inverse rule: inspecting a worktree from outside. The existing guard refuses mutation from main; the symmetric trap is observational cd .forge/worktrees/<ID> && git log poisoning cwd for every subsequent command in the session. Rule: use git -C <path> <cmd> for read-only inspection from any session not pinned to a worktree by /pickup-task. Includes a wrong-vs-right cd vs git -C example pair.
  • skills/pickup-task/SKILL.md — rewrote step 1 to mandate tracker-first lookup with an explicit warning that phases.yaml status 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.yaml is a stale cache."
  • CONTRIBUTING.md — added a manual git grep recipe 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:

  1. Recommended already-shipped tickets twice (FORGE-99, FORGE-94) because I grep'd plans/phases.yaml status: fields instead of querying Linear — exactly the failure §Source of truth now forbids.
  2. Stray cd .forge/worktrees/FORGE-88 && git log poisoned 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-worktree hydrated a stale CRITICAL.md that, if committed, would have silently reverted FORGE-88's src/harnesses/** codex-auto-review glob. Filed as P1 follow-up to FORGE-98 with repro details and acceptance criteria.

Test plan

  • npm run typecheck — clean
  • npm test — 1276 passed / 0 failed / 15 skipped
  • npm run build — dual ESM+CJS bundles emit cleanly
  • node dist/bin/forge.cjs --version — smoke OK
  • gitleaks detect — no leaks
  • Manual diff review — confirmed only the 7 intended files
  • No CRITICAL.md path touched — multi-model review not required

Linked

Closes FORGE-106.
Related: FORGE-136 (filed mid-implementation).

🤖 Generated with Claude Code

firatcand and others added 2 commits May 18, 2026 16:47
…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>
@firatcand firatcand merged commit fd3bde2 into main May 18, 2026
10 checks passed
@firatcand firatcand deleted the feat/FORGE-106 branch May 18, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant