tokensafe / rules
AGENTS.md47 starsChanged 2 days agoApache-2.0View on GitHub
When interacting within this environment, you MUST follow strict token economy guidelines: Execute the specified action directly based on these extracted parameters.
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/tokensafe.mdcCursor rule
- token-optimizerSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
13 rules. About 0 are common, 3 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
When interacting within this environment, you MUST follow strict token economy guidelines:
- Very specific: line 11
When a user input or system message is prefixed with [TOCP Compressed Intent], it follows the lean S-Expression syntax: (ACTION …
- Distinctive: line 23
No Conversational Filler: Never include courtesy greetings or sign-offs (e.g., "Certainly!", "Sure, I can help", "Let me know if you need …
- Very specific: line 25
Diff-Centric Responses: Never reprint entire unmodified files or long boilerplate blocks.
- Distinctive: line 26
Dense Formatting: Use compact bullet points and direct technical prose.
- Very specific: line 27
Repeat Read Deduplication: Never re-read unchanged files or symbols in the same session.
- Very specific: line 28
Compact Test Output Execution: Run unit tests via tokensafe tests [cmd] or tokensafe wrap '<cmd>' so passing suites return a 1-line summary …
- Very specific: line 29
Multimodal Image Isolation (Prompt Cache Protection): Never load raw .png/.jpg/.webp screenshots into a long (>150k-token) coding session …
- Very specific: line 30
Startup Snapshot Utilization: Check [TokenSafe Workspace Snapshot] on turn 1 before running exploratory ls or git status.
- Very specific: line 35
Symbol, Bundle & External Type Reads (
smart_read_file): Call tokensafe:smart_read_file(path, symbol) (dep_mode="signature" default, … - Very specific: line 38
Session & Context Hygiene (
session_context): Call tokensafe:session_context(action="budget", model=...) before large tasks. - Very specific: line 39
Utilities (
run_helper): Call tokensafe:run_helper(action=...) for: - Very specific: line 49
Bounded Reads & Styles: Never call raw read_file without StartLine/EndLine on files > 100 lines.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!--
Rule: Token-Optimized Communication Protocol (TOCP)
Trigger: always_on
-->Token-Optimized Communication Protocol (TOCP)
When interacting within this environment, you MUST follow strict token economy guidelines:
1. Ingress Intent Decoding
When a user input or system message is prefixed with [TOCP Compressed Intent], it follows the lean S-Expression syntax:
(ACTION [target_file] [scope_symbol] [[traits...]] ["residual_intent"])
ACTION:REFACTOR,DEBUG,CREATE,OPTIMIZE,EXPLAIN,AUDIT,TEST,RUN.target_file: Primary file path to inspect or edit.scope_symbol: Targeted function, method, class, or identifier.traits: Constraints such as[async redis cache zero_alloc typesafe unit_test].residual_intent: Minimal context delta.
Execute the specified action directly based on these extracted parameters.
2. Zero-Fluff Output Directives (Egress Optimization)
- No Conversational Filler: Never include courtesy greetings or sign-offs (e.g., "Certainly!", "Sure, I can help", "Let me know if you need anything else").
- Surgical Code Edits, Batching & Zero In-Place Stream Editing: Prefer
tokensafe:apply_edits(edits=[...], verify="npm test")for >=2 hunks/files or edit + verify loops. For single tweaks, useedit_filewith exactTargetandReplacement. NEVER run terminal stream editors (sed -i,perl -i,awk -i) on source code (hard-blocked by TokenSafe Guard), and never suppress errors (2>/dev/null). - Diff-Centric Responses: Never reprint entire unmodified files or long boilerplate blocks. Reference file lines instead (e.g.,
wallet.ts#L42-L50). - Dense Formatting: Use compact bullet points and direct technical prose.
- Repeat Read Deduplication: Never re-read unchanged files or symbols in the same session. Reuse the skeleton or pointer reference (
// [TokenSafe: Pointer Hit ...]) returned earlier; passforce_full=trueonly after compaction or as a fresh subagent. - Compact Test Output Execution: Run unit tests via
tokensafe tests [cmd]ortokensafe wrap '<cmd>'so passing suites return a 1-line summary (PASS: ...), preserving full output only on failure. - Multimodal Image Isolation (Prompt Cache Protection): Never load raw
.png/.jpg/.webpscreenshots into a long (>150k-token) coding session (triggers KV-cache invalidation). Delegate visual inspection to a subagent returning text-only findings. - Startup Snapshot Utilization: Check
[TokenSafe Workspace Snapshot]on turn 1 before running exploratorylsorgit status. - Zero-Spill Response Budget & Reversible Stash: TokenSafe MCP responses are capped per response (not per block) at ~8.8 KB of UTF-8 text, with headroom left for JSON escaping, to prevent Antigravity
output.txtdisk spills. Folded content carries a[TokenSafe folded: #hash ...]anchor and is archived in the stash; calltokensafe:run_helper(action="expand", hash="...")to restore it. If the stash write fails, the response is still truncated and the marker states that the raw copy is unavailable.
3. Architecture & Code Navigation Directives (7 Consolidated MCP Tools)
- Search (
scoped_search): Terminalgrep/egrep/rg/findon source files are BLOCKED. Calltokensafe:scoped_search(query, path=".", scope="code")(supportsmode="auto|text|regex|glob|fuzzy|git") or passqueries=[...]for up to 20 concurrent queries in 1 call (<70ms local). - Symbol, Bundle & External Type Reads (
smart_read_file): Calltokensafe:smart_read_file(path, symbol)(dep_mode="signature"default,"full"when needed,force_full=trueon pointer miss; OpenAPI/Prisma/GraphQL/SQL auto-slice viasymbol). Passtargets=[{path, symbol}](2–8 targets) to bundle files with deduplicated imports, orpackage_name+symbolfor 3rd-party.d.tsinterfaces. - Architecture, API Surface & Directory Trees (
repo_map): First inspect God Nodes viatokensafe:repo_map(view="graph", project_path=...)before crawling files. Useview="api"for exported types/interfaces andview="tree"(neverls -la). - Multi-File Edits (
apply_edits): Batch >=2 hunks/files and optionalverifycommands in a single turn. - Session & Context Hygiene (
session_context): Calltokensafe:session_context(action="budget", model=...)before large tasks; whenwarning/criticalor Grade C/F, callaction="compact"withtranscript_path. Useaction="prune"for superseded reads,action="mistakes"for anti-stuck dead-end memory, andaction="metrics"for savings analytics. - Utilities (
run_helper): Calltokensafe:run_helper(action=...)for:"expand"(hash): restore stashed#hashcontent"web"(url): fetch clean Markdown docs (-80-95% tokens, L1/L2/L3 cached)"deps"(package_name,lockfile_path): point lockfile lookup in <50 tokens"sanitize"(command,cwd): rewrite noisy shell/test commands"guard"(command/code,file_path): pre-flight security/hygiene audit"diff"(diff): slice unified git diffs"image"(image_path,max_edge=1024): downscale screenshots (-50-75% vision tokens)"compress"(prompt): TOCP S-expression compression
- Universal OUMV Protocol (
oumv— Mandatory When Supported): When a project uses an OUMV-supported stack (frontend/reactVite,frontend/vue,frontend/solid,backend/go,backend/fastapi), ALWAYS prefertokensafe:oumv(action="status"|"observe"|"understand"|"verify"|"mutate"|"graph", ...)BEFORE full file crawls, rawcurl, or headless browsers — even for read/edit tasks (static AST OUMV works offline without running dev/build). For Vite+React, usetokensafe devto start live OUMV with zero repository footprint. In mixed monorepos (e.g. React + Node.js), inspectoumv(action="status")/[TokenSafe OUMV Workspace Matrix]: useoumvon supported profiles and fall back torepo_map+smart_read_file+scoped_searchfor unsupported stacks (backend/node). Multi-root sessions: the routing brief is classified per workspace root — a verdict for one repo NEVER applies to another. Before editing a repo outside the roots listed in the brief, calltokensafe:oumv(action="status", workspace_dir="<that repo>"); never conclude "OUMV is unavailable" from a single-root brief. - Bounded Reads & Styles: Never call raw
read_filewithoutStartLine/EndLineon files > 100 lines.smart_read_filepreserves CSS/SCSS/Tailwind design tokens (:root,@theme) in full.
4. Turn Token Savings Footer (Proof-of-Savings — always in English)
At the end of your response for any turn where tools were executed, files were inspected, commands were sanitized, or prompts were compacted, append a compact 1-line footer:
⚡ **TokenSafe Turn Savings**: +<tokens> tokens saved on this turn (<breakdown>) | Cumulative Total: <total> tokens (≈$<usd> approx)
Example:
⚡ **TokenSafe Turn Savings**: +3,520 tokens (~88%) | Cumulative Total: 3.04M tokens (≈$4.56 approx)
5. Secret Leak Prevention Directive (Zero Hardcoded Fallbacks)
- Never Hardcode Credential Fallbacks: Never provide real private keys, API secrets, access tokens, or webhook secrets as default fallback arguments in
os.environ.get(),os.getenv(), orprocess.env. If an environment variable is absent, raise an explicit configuration error or use an empty string / test mock. Real credentials must exist strictly in environment variables. - Leak Prevention Notification (English):
Whenever a tool execution, code edit, or command attempts to write or commit a hardcoded secret fallback, block it and include an explicit notification alert in your response:
🛡️ **TokenSafe Security Guard**: Prevented secret / private key leak into git (<target_file>: <details>)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

