Skip to content

docs(claude-code): slim AI instructions (~54% token reduction)#1491

Merged
JeremyDev87 merged 1 commit into
masterfrom
docs/slim-ai-instructions
Apr 11, 2026
Merged

docs(claude-code): slim AI instructions (~54% token reduction)#1491
JeremyDev87 merged 1 commit into
masterfrom
docs/slim-ai-instructions

Conversation

@JeremyDev87
Copy link
Copy Markdown
Owner

Summary

Reduces the text Claude Code auto-injects into every session start from 6,802 → 3,097 tokens (−3,705 / −54.5%, char/3.5 approximation).

Originally produced by Codex running a token-reduction prompt, then verified by Claude Code for rule preservation, path consistency, and actual token measurement.

What moved

File Change Δ tokens
.claude/rules/custom-instructions.md Agent catalog (37+ row table) removed — now fetched on demand via mcp__codingbuddy__get_agent_details / list_agent_stacks. Canonical list at packages/rules/.ai-rules/agents/README.md. −2,590
.claude/rules/permission-presets.mddocs/claude-code/permission-presets.md Reference material relocated out of the auto-loaded tree. Byte-identical move; git detects as rename. CLAUDE.md gets a one-line pointer for discoverability. −1,073
CLAUDE.md Tool Priority section trimmed to a layered summary + link to .claude/rules/tool-priority.md for the full matrix. New Permission Presets pointer. −42
.gitignore Adds .claude/worktrees/ and .local-backups/ — local runtime/backup artifacts that should never surface as untracked. 0
Total auto-injected 6,802 → 3,097 −3,705 (−54.5%)

Mandatory rules preserved (verbatim)

  • TDD_CONTINUITY_RULE.claude/rules/custom-instructions.md:31
  • CODINGBUDDY_CRITICAL_RULE (keyword mode detection) — .claude/rules/custom-instructions.md:48
  • SPECIALIST_COUNCIL_RULE.claude/rules/custom-instructions.md:61

Behavioral impact

None. The project CLAUDE.md and parse_mode MCP response still control actual workflow behavior. Dropping the agent catalog from the auto-load layer does not remove any behavior — the activate MCP tool still recommends primaryAgent + specialists per task, and users who need freestyle selection can list_agent_stacks on demand.

Cache note: first 1–2 sessions after merge will re-cache the new prompt (one-time re-cache cost). Net savings apply from roughly the second session onward.

Cost impact (Opus 4.6 user, ~10 sessions/day)

  • Per-session cache-miss savings: ~3.7K tokens × $15/MTok ≈ $0.055 / session
  • Monthly: ~$16.5 (estimate, depends on actual session cadence)
  • Not revolutionary, but meaningful over a year.

Test plan

  • yarn workspace codingbuddy npm audit --severity high — ✅ No audit suggestions
  • yarn workspace codingbuddy-claude-plugin npm audit --severity high — ✅ No audit suggestions
  • yarn workspace landing-page npm audit --severity high — ✅ No audit suggestions
  • ajv-cli validate packages/rules/.ai-rules/agents/*.json — ✅ all valid
  • markdownlint-cli2 packages/rules/.ai-rules/**/*.md — ✅ 102 files, 0 errors
  • Grep for stale .claude/rules/permission-presets references — only CLAUDE.md hit, already updated
  • Grep for 3 MANDATORY rule blocks in the trimmed custom-instructions.md — all present
  • git diff verifies docs/claude-code/permission-presets.md is byte-identical to the old .claude/rules/permission-presets.md (git rename detection confirms)
  • Post-merge: new Claude Code sessions should continue to honour PLAN/ACT/EVAL/AUTO keyword detection, specialist council dispatch, and TDD RED-GREEN-REFACTOR rules
  • Post-merge: manually confirm that mcp__codingbuddy__get_agent_details("<name>") still returns full agent metadata when needed

Reduces the text Claude Code auto-injects at every session start from
~6,802 tokens to ~3,097 tokens (−3,705 tokens / −54.5%, measured with
char/3.5 approximation) by:

- Moving the full agent catalog out of custom-instructions.md.
  Agent metadata is now fetched on demand via
  mcp__codingbuddy__get_agent_details / list_agent_stacks, and the
  canonical list lives in packages/rules/.ai-rules/agents/README.md.
  Saves ~2,590 tokens/session.

- Relocating permission-presets.md from .claude/rules/ (auto-loaded
  into every session) to docs/claude-code/ (reference material,
  not auto-loaded). Saves ~1,073 tokens/session. CLAUDE.md gets a
  one-line pointer to the new location so discoverability stays
  intact. The file move is byte-identical and git detects it as
  a rename.

- Trimming CLAUDE.md's Tool Priority section to a layered summary
  with a link to .claude/rules/tool-priority.md for the full matrix.
  Saves ~42 tokens/session.

All three MANDATORY rules are preserved verbatim in
custom-instructions.md:

- TDD_CONTINUITY_RULE (line 31)
- CODINGBUDDY_CRITICAL_RULE — keyword mode detection (line 48)
- SPECIALIST_COUNCIL_RULE (line 61)

No behavioral change for any Claude Code session. Only the
per-session context size drops. Cache-invalidation note: the first
few sessions after this merge will re-cache the new prompt, so
initial savings apply from roughly the second session onward.

Also gitignores .claude/worktrees/ and .local-backups/ — both are
local runtime/backup artifacts that were incorrectly surfacing as
untracked and should never be committed.

Original work by Codex running a token-reduction prompt; verified
by Claude Code for mandatory-rule preservation, path consistency,
downstream references, and actual token measurement.
@JeremyDev87 JeremyDev87 added the documentation Improvements or additions to documentation label Apr 11, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codingbuddy-landing Ready Ready Preview, Comment Apr 11, 2026 5:54pm

@JeremyDev87 JeremyDev87 self-assigned this Apr 11, 2026
@JeremyDev87 JeremyDev87 merged commit 64168b1 into master Apr 11, 2026
26 checks passed
@JeremyDev87 JeremyDev87 deleted the docs/slim-ai-instructions branch April 11, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant