cd /news/developer-tools/additional-instructions-for-agents-m… · home topics developer-tools article
[ARTICLE · art-46889] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Additional instructions for AGENTS.md focusing on token optimization

A developer introduced a set of guidelines for an AI agent's AGENTS.md file to optimize token usage. The instructions prioritize using a pre-computed AST knowledge graph (graph.json) and the rtk CLI proxy to reduce token consumption by 60-90%. The workflow emphasizes retrieving minimal information, using ast-grep for code searches, and avoiding full directory reads.

read2 min views1 publishedJul 1, 2026

Always retrieve the smallest amount of information necessary. Escalate only when necessary. Stop escalating as soon as sufficient information has been obtained.

Preferred order:

  • Need code structure? graph.json

. - Need symbols? ast-grep

. - Need repository metadata? rtk

. - Need implementation? Source files.

  • Use repository-wide search as last resort

Avoid reading entire directories or the whole repository unless explicitly requested.

rtk is a CLI proxy that filters and compresses command outputs, saving 60-90% tokens. Use rtk

whenever possible because it preserves the relevant information while reducing LLM token consumption.

Always prefix shell commands with rtk

:

ls -la           rtk ls -la
git status       rtk git status
git log -10      rtk git log -10
docker ps        rtk docker ps

Other examples where you can use rtk

: Other examples where you can use rtk

:

rtk tree
rtk read
rtk cat
rtk git diff
rtk diff
rtk npm run test
rtk curl <url>
rtk pytest
rtk jest
rtk vitest
rtk playwright test
rtk lint
rtk prettier --check .

A pre-computed AST knowledge graph (graph.json

) is available at: graphify-out/graph.json

Use graph.json

before searching or reading multiple source files.

Workflow:

  • Read graph.json

. - Identify the relevant symbols, files, and dependency paths.

  • Read only the source files required for the task.
  • Avoid scanning unrelated files.

Use the graph for:

  • dependency tracing
  • call-path discovery
  • identifying high-centrality modules
  • impact analysis before refactoring
  • locating symbol definitions

Never read an entire directory simply to locate a symbol. Use graph.json

to locate the symbol first, then read only the relevant files.

The graph is generated from AST extraction and represents extracted structural relationships only. Treat graph edges as authoritative for structural relationships. Do not infer dependencies that are absent from the graph.

Prefer ast-grep

over grep

whenever searching source code.

Use ast-grep

for:

  • locating function definitions
  • locating class definitions
  • locating method implementations
  • finding imports
  • matching AST patterns
  • performing structural search

Use grep

only for:

  • Markdown
  • JSON
  • YAML
  • log files
  • generated text
  • plain-text configuration

Avoid using grep

to search programming language source code when ast-grep

can answer the query.

── more in #developer-tools 4 stories · sorted by recency
── more on @rtk 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/additional-instructi…] indexed:0 read:2min 2026-07-01 ·