feat(rules): add built-in token-efficiency rule - #239
Closed
jeff-r2026 wants to merge 1 commit into
Closed
Conversation
Distill the team's "Effective Token" guidelines into an AI-actionable built-in rule, deployed by `teamai pull` alongside teamai-recall via the existing builtin-rules mechanism. The rule covers the guideline clauses that actually change agent behavior: grounding over memory (anti-hallucination), search before full-file reads with bounded ranges, tools/scripts over model reasoning, minimal output, persisting durable info to files, and YAGNI. Human-only actions from the guidelines (session isolation, /compact, /clear) are intentionally left out since they can't be enforced via a system-prompt rule. Unlike teamai-recall, token-efficiency is always deployed and not gated by the recall toggle. It is excluded from `teamai push` (EXCLUDED_RULE_NAMES) and cleaned up on uninstall (BUILTIN_RULE_NAMES), both automatically. Co-Authored-By: Claude Opus 4.8 <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.
What
Adds a CLI built-in rule
token-efficiency.md, deployed byteamai pullto every installed tool's rules directory via the existingbuiltin-rulesmechanism (same path asteamai-recall).It distills our internal Effective Token 使用规范 into the subset of clauses that actually change agent behavior at the system-prompt layer:
grep/glob to locate, then bounded-range reads; narrow command output at the sourcesed/CLIs, not step-by-step reasoningHuman-only guideline actions (session isolation,
/compact,/clear) are intentionally excluded — they can't be enforced through a system-prompt rule.Design notes
teamai-recall,token-efficiencyis always deployed (not gated by the recall toggle) — it's a general guardrail.teamai pushviaEXCLUDED_RULE_NAMESand cleaned up on uninstall viaBUILTIN_RULE_NAMES— no separate wiring needed.docs/usage-guide.mdanddocs/usage-guide.zh-CN.md(new "Built-in rules" table).Test Plan
npx tsc --noEmit— no errorsnpx vitest run— 1767 passed, 0 failed (added 3 cases inbuiltin-rules.test.ts)npm run build— build successdeployBuiltinRulesagainst a throwawayHOME; confirmedtoken-efficiency.md(53 lines) lands in.claude/rules/alongsideteamai-recall.md, and is still deployed whenskipRecall: true🤖 Generated with Claude Code