Skip to content

βœ‚οΈπŸ›‘οΈ refactor: slim CLAUDE.md 268β†’149 + extract headless-fallback / mcp-errors / direct-mode / push-gate to skills#124

Merged
ZaxShen merged 2 commits into
devfrom
feat/headless-bro-doctrine
Apr 26, 2026
Merged

βœ‚οΈπŸ›‘οΈ refactor: slim CLAUDE.md 268β†’149 + extract headless-fallback / mcp-errors / direct-mode / push-gate to skills#124
ZaxShen merged 2 commits into
devfrom
feat/headless-bro-doctrine

Conversation

@ZaxShen
Copy link
Copy Markdown
Contributor

@ZaxShen ZaxShen commented Apr 26, 2026

Summary

Two changes bundled β€” both touch the same files (CLAUDE.md + skill set), so shipping together avoids interleaving conflicts.

1. Headless-bro doctrine (original PR scope)

L6 run #24966945645 revealed bro halts in headless claude -p mode whenever a skill calls AskUserQuestion β€” no Human β†’ error β†’ halt. 3 of 4 wired flows died this way. Plus 95-anonymous-cold-restart showed bro short-circuiting the first-action chain on casual messages.

Doctrine fix:

  • First-action chain clarified: "No exceptions. Casual messages like @bro hi still run the full chain."
  • 6 skills updated:
    • tmb_first-run-onboarding, tmb_branch-id-proposal, tmb_planning-difficult get ## Headless fallback sections with documented per-question defaults.
    • tmb_reonboard HALTs in headless mode (policy keys would silently break git-guards.sh otherwise).
    • tmb_skill-creator, tmb_agent-creator HALT (silent file-creation in CI is the foot-gun).
  • Every fallback must record both ledger_log(event_type='headless_fallback', ...) AND discussion_append(kind='note', ...) β€” audit trail non-negotiable.

2. CLAUDE.md slim-down (per user feedback during review)

User flagged CLAUDE.md as way too long (268 lines, recommended under 200, ideally 60). The headless-fallback rule itself was contributing to the bloat β€” belongs in a skill, not the always-loaded persona.

Extracted 4 reactive skills (load only when triggered, not every turn):

Skill Trigger Was lines
tmb_headless-fallback AskUserQuestion errors / TMB_HEADLESS=1 17
tmb_mcp-error-handling MCP returns is_error: true 8
tmb_direct-mode ≀3-line single-file fix candidate 17
tmb_push-gate git push blocked / "review before push" 15

CLAUDE.md retains only what bro needs on EVERY message: trigger rule, identity, MCP caller rules, first-action chain, routing table, code-touching ask chain, skills lookup, catchphrase. Reference content (agent layer detail, state locations) collapsed to pointers at CONTRIBUTING.md and docs/architecture/FLOWS.md.

Net: 268 β†’ 149 lines (44% reduction). Still over the 60-line aspirational target β€” further compression would lose essential routing β€” but well under the 200 ceiling.

Test plan (after merge)

  • Re-trigger l6-dogfood.yml on dev
  • Confirm 95-anonymous-cold-restart now passes BOTH outcome AND trajectory_required (bro runs full first-action chain on @bro hi)
  • Confirm 01-onboarding now passes (bro completes onboarding with documented defaults via tmb_headless-fallback)
  • Confirm 02-simple-task progresses past the branch-id-proposal stall (auto-accept default)
  • D-direct-mode: bro should now load tmb_direct-mode skill explicitly for the typo, hit the direct_mode_used ledger event. If still failing, that's a separate Direct-Mode-detection bug.
  • Inspect new artifact: confirm headless_fallback ledger events appear with the documented questionβ†’default mapping.

ZaxShen added 2 commits April 26, 2026 14:22
L6 run #24966945645 (artifact #122) confirmed bro halts in `claude -p`
mode whenever a skill calls AskUserQuestion β€” no Human, error, halt.
3 of 4 wired flows died this way. Plus 95-anonymous-cold-restart
revealed bro short-circuiting the first-action chain on casual
messages, contradicting the documented "every triggered message" rule.

Doctrine fix:

1. **CLAUDE.md** gains an "AskUserQuestion fallback β€” never halt"
   section. Every fallback MUST record both `ledger_log(event_type=
   'headless_fallback', ...)` AND `discussion_append(kind='note', ...)`
   so the autonomous decision is auditable.

2. **First-action chain** clarified: "No exceptions. Casual messages
   like @bro hi still run the full chain." Removes the wiggle-room
   bro was using to skip identity_get/config_get/issue_resume.

3. **4 in-DB skills** (tmb_first-run-onboarding, tmb_branch-id-proposal,
   tmb_reonboard, tmb_planning-difficult) get a "## Headless fallback"
   section listing question→default→audit-write protocol.

4. **2 file-writing skills** (tmb_skill-creator, tmb_agent-creator)
   get a "## Headless mode β€” HALT" section. Auto-approving silent
   skill/agent generation in CI is the foot-gun the rule guards
   against; halt with `ledger_log(event_type='headless_creator_blocked')`
   instead.

5. **tmb_reonboard** also halts (re-onboarding flips policy keys that
   drive git-guards.sh; silent fallback could break the project's
   git workflow with no audit trace).

Defaults table summary:
- identity name β†’ "Anonymous" (recoverable via tmb_reonboard)
- branching_model β†’ github-flow
- pr_target β†’ main
- protected_branches β†’ ["main"]
- branch-id-proposal confirm β†’ "Yes, proceed"
- planning-difficult scope β†’ "proceed as proposed"
User feedback on PR #124: AskUserQuestion fallback (+ much more) belongs
in skills, not in the always-loaded CLAUDE.md. Recommended target:
under 200 lines, ideally 60.

Extracted to new reactive skills (load on trigger, not on every turn):

- tmb_headless-fallback β€” AskUserQuestion fallback doctrine + ledger/discussion audit (was the new section from #124)
- tmb_mcp-error-handling β€” is_error halt rule + forbidden-tools list
- tmb_direct-mode β€” ≀3-line single-file bypass protocol
- tmb_push-gate β€” pr-reviewer-at-push-time orchestration

CLAUDE.md retains only what bro needs on EVERY message:

- Trigger rule
- Identity / role / two-layer agent model (compressed)
- MCP caller identity + forbidden-tools one-liner
- First-action chain (no exceptions for casual messages β€” preserved from #124)
- Routing decision table
- Code-touching ask chain (with skill pointers)
- "Skills bro loads reactively" lookup table
- Catchphrase + communication style
- Reference pointers (state, perf, config keys)

Net: 268 β†’ 149 lines (44% reduction). Reference-style sections
(Agents shipped, Where state lives) collapsed to one-liners pointing
at CONTRIBUTING.md and existing architecture docs.
@ZaxShen ZaxShen changed the title πŸ›‘οΈ feat(bro): headless fallback doctrine for AskUserQuestion βœ‚οΈπŸ›‘οΈ refactor: slim CLAUDE.md 268β†’149 + extract headless-fallback / mcp-errors / direct-mode / push-gate to skills Apr 26, 2026
@ZaxShen ZaxShen merged commit ba055d9 into dev Apr 26, 2026
5 checks passed
@ZaxShen ZaxShen deleted the feat/headless-bro-doctrine branch April 26, 2026 21:30
ZaxShen added a commit that referenced this pull request Apr 26, 2026
…rotocol to skills/docs (#126)

User feedback: 'audit every single word' β€” CLAUDE.md is loaded EVERY
turn, must contain only what bro needs every turn (trigger, identity,
routing, reactive skills lookup). Detail and reference moved out.

Extracted:

- 'Subagent prompt precedence' (4 lines) β€” DELETED. Subagent prompts
  declare themselves; CC handles dispatch automatically.
- 'Two-layer agent model' (5 lines) β†’ new docs/AGENTS.md.
- 'Forbidden tools' detail (5 lines) β†’ expanded existing
  tmb_mcp-error-handling skill (now also covers policy-key writes).
- First-action chain rationale paragraph (3 lines) β†’ compressed to
  the section header itself ('no exceptions, no shortcuts').
- 'Bro verification' + 'Tool-call batching' detail (5 lines) β†’ already
  documented in planning skills; CLAUDE.md now points there.
- 'Direct ops' verbose section (3 lines) β†’ folded into routing table
  as one row.
- 'Concerns + second opinions' (8 lines) β†’ new tmb_concerns-protocol
  skill (procedural, loads on demand when bro disagrees).
- 'Reference' pointer block (7 lines) β†’ new docs/REFERENCE.md.

Net: 268 β†’ 99 lines (63% reduction over 3 PRs: #124, #125, this one).

What's left in CLAUDE.md:
- Trigger rule (when bro activates) β€” must be every turn
- Identity (compressed Role) β€” must be every turn
- MCP caller-id rule (every-turn rule)
- First-action chain (mandatory routine on every triggered message)
- Routing table (decision tree)
- Code-touching ask chain (the planning workflow diagram)
- Reactive skills lookup (so bro knows what to load when)
- Catchphrase + Communication style (identity)
- Reference pointer (2 lines pointing at docs/)

Approaching the 60-line aspirational target β€” further compression
would gut essential routing.

Co-authored-by: Zax Shen <ZaxShen@users.noreply.github.com>
ZaxShen added a commit that referenced this pull request May 20, 2026
Adds a "Pre-write check β€” no noise-citations" rule + Why section to
tmb_agent-creator and tmb_skill-creator. Audits and fixes existing
plugin prompt files (CLAUDE.md / agents/ / skills/ / templates/agents/)
for issue-number citations, memory file paths, origin attributions,
and tombstone commentary.

Re-does the AskUserQuestion mandate: adds CLAUDE.md "## Asking the
Human" section with inline constraints (no memory-path tail), and the
corresponding tmb_review-findings entry under "Bro Persona Patterns"
without a "Caught in" line.

Drops the "Caught in: PR / commit / file:line" row from the
review-findings template β€” the field itself trained future authors to
write the noise-citations the doctrine now forbids.

Closes #124. Re-does #95.
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