antis-optimizer
Give AI coding agents the exact lines, not the whole file.
One command lists every symbol with its line range; one more prints just that function. Around that core: scan repo bloat and sync ignore rules across every AI tool so agents stop wasting tokens on junk folders and oversized files.

Interactive Website & Diff Simulator · v1.6.0 Release · Changelog · Contributing Guide · Security
Why · Quick start · How it works · Languages · Commands · Agent skill · Safety · Works with
Why Use This?
When you ask an AI assistant (OpenCode, Claude Code, Cursor, Codex, Gemini CLI, Antigravity, VS Code / Copilot, or Windsurf) to explore or edit a project, two things silently burn your context window and slow it down:
- Junk files sneaking into searches: build folders (
dist/, build/), forgotten git worktrees, massive JSON dumps, and lockfiles get scanned over and over—and every AI tool checks a different ignore file (.ignore, .contextignore, .jcodemunch.jsonc, .cursorignore, .geminiignore, etc.).
- Reading huge files top-to-bottom: to edit one 30-line function or JSON section, the AI reads an entire 800-line file into memory—and stale line numbers in docs break after the next edit.
antis-optimizer fixes both in seconds with a fast Node CLI and tiny, auto-updating repo docs.
🚀 Try It in 10 Seconds
Run a read-only audit on any repo — nothing is written to your project:
npx antis-optimizer --audit
Or install globally so antis-optimizer is always available. The install has zero dependencies and uses the built-in lexer; add typescript globally (npm install -g typescript) only if you want exact Compiler-AST spans for TS/JS:
npm install -g antis-optimizer
antis-optimizer --audit
The 4 commands you will actually use
antis-optimizer --audit # 1. what is bloating this repo? (read-only)
antis-optimizer --sync-ignores # 2. preview ignore changes (add --write to apply)
antis-optimizer --outline src/app.ts # 3. list symbols with exact line ranges
antis-optimizer --slice src/app.ts loadUser # 4. print just that one function
Real output from this repository:
$ antis-optimizer --outline scripts/repo-index.cjs redact
=== OUTLINE scripts/repo-index.cjs (3074L, 149453B, imports=5, filter="redact") ===
L88-L92: function redactSecrets(text)
$ antis-optimizer --slice scripts/repo-index.cjs isInsideRoot
landmark: scripts/repo-index.cjs:L112-L115
function isInsideRoot(root, fullPath) {
const rel = path.relative(path.resolve(root), path.resolve(fullPath));
return !rel.startsWith('..') && !path.isAbsolute(rel);
}
$ antis-optimizer --verify
PASS doc-budgets: 1<=80L | PASS landmarks: verified | PASS nested-git: 1 | PASS ignore-parity: 3(70) | PASS repo-index syntax: ok
A 3,074-line file answered in 5 lines — that is the whole idea.
Nothing is modified unless you pass --write. To undo an ignore sync, delete or git checkout the ignore files it touched.
🔄 How It Works
- Audit your repo (
--audit): Counts real source files vs. junk, flags large files (>= 15 KB), detects common stacks (Node, Python, Rust, Go, Java Maven/Gradle, Swift, Ruby, PHP, Elixir, .NET), and recommends a right-sized setup (for tiny repos, it skips extra docs completely so setup never costs more tokens than it saves).
- Sync ignore rules everywhere (
--sync-ignores --write):
- Always syncs
.ignore.
- Mirrors exclusions into
.contextignore, .jcodemunch.jsonc, and repo-present tool ignore files (.cursorignore, .cursorindexingignore, .geminiignore, .aiexclude, .codeiumignore, .rooignore, .clineignore, .aiderignore, .claudeignore) only when that tool or config already exists in your repo.
- Anti-bloat: never creates unwanted dotfiles or modifies
opencode.json[c], which stays read-only with an opencode-ignore / watcher.ignore check.
- Writes
.contextignore in Token Optimizer's own matching style (dist/ becomes */dist/*). It never blocks images or PDFs there, because Token Optimizer denies the whole Read on a match.
- Preserves your
# comments (grouped in the file header), JSONC // comments, and .gitignore ! negations.
- Keep-list: a
!path line in .ignore (for example !_work/ or !decompiled/) marks a folder as intentional. It is never suggested as junk, stays readable in .contextignore, and --verify accepts it.
- Guessed backup/large directories and plain-text files over 1 MB are flagged for review rather than auto-ignored. Python virtual environments are found by their
pyvenv.cfg, whatever the folder is called.
- Jump straight to exact lines (
--outline, --slice): Lists functions, classes, headings, keys, blocks, and sections with exact file:Lstart-Lend ranges (see Supported Languages), and slices exact AST/lexer symbol spans or :Lstart-Lend line ranges. Uses the TypeScript Compiler when installed, with a fast built-in parser fallback.
- Keep docs fresh automatically (
--sync-landmarks --write, --verify): Re-anchors shifted line numbers after you edit code and confirms everything passes in a single line (including 0-doc Tier 0 repos and AGENTS.override.md).
🌐 Supported Languages
| Kind |
--outline / --slice support |
| Code |
TS / JS / JSX / TSX, Python, Rust, Go, C / C++, C#, Java, Kotlin (.kt / .kts), Swift, PHP, Ruby, Elixir (.ex / .exs), SQL, Shell / Bash (.sh / .bash) |
| Markup & components |
HTML, Svelte, Vue, Astro, CSS |
| Config & docs |
JSON / JSONC, YAML, TOML, Markdown |
TS/JS use the real TypeScript Compiler AST when typescript is installed; everything else (and TS/JS without it) uses the built-in lexer.
📊 Modeled Impact
These are modeled estimates, not benchmark measurements. They compare typical full-file reads and verbose logs against capped CLI output at ~4 chars/token. Your numbers depend on repo size and how your agent reads files — run --audit on your own repo for real byte counts.
| Common Task |
Without antis-optimizer |
With antis-optimizer |
Saved |
| Searching a repo |
Scans dist/, caches, media, worktrees (35k–120k+ tokens) |
Junk blocked across all tools (~1.2k tokens) |
~96–99% |
| Checking a huge JSON / HTML file |
Reads the whole file into context (8k–15k tokens) |
--slice pulls just the section you need (~700 tokens) |
~91% |
| Finding a function in big files |
Opens multiple full files (12k+ tokens) |
--outline shows exact file:Lstart-Lend lines (~550 tokens) |
~95% |
| Running checks after edits |
Dumps pages of build logs (2.5k–9k tokens) |
--verify prints one PASS line (~35 tokens; logs only on fail) |
~98% |
| Resuming after context compaction |
Re-reads files from scratch (15k+ tokens) |
--handoff saves a <= 2 KB state summary (~500 tokens) |
~94% |
🧭 Command Cheat Sheet
Every command caps its output below 3,500 characters (and --handoff below 2 KB), automatically redacts API keys/tokens, and refuses .env / private key files.
| Command |
What It Does |
antis-optimizer --audit |
Scans junk/large files and recommends the lightest setup tier for your repo |
antis-optimizer --detect |
Detects AI hosts (OpenCode, Claude, Cursor, Gemini CLI, Codex, Copilot, Windsurf, Cline/Roo/Aider, RTK), MCPs, stacks, and nested .git folders |
antis-optimizer --sync-ignores --write |
Syncs .ignore plus active repo tool ignores (.contextignore, .jcodemunch.jsonc, .cursorignore, .geminiignore, etc.) without bloating unused repos or editing opencode.json[c] |
antis-optimizer --outline <file> [filter] |
Shows symbols, SFC blocks, config keys, or Markdown headings and exact Lstart-Lend line numbers |
antis-optimizer --slice <scope> [symbol] / <file>:Lstart-Lend |
Extracts one JSON/JSONC section, AST/lexer symbol span, or explicit line range |
antis-optimizer --map |
Prints a compact overview map, .opencode/skills/, and project landmarks |
antis-optimizer --sync-landmarks --write |
Updates shifted file:Lstart-Lend references in AGENTS.md / AGENTS.override.md / INDEX.md |
antis-optimizer --verify [--exec "<cmd>"] |
Verifies doc size caps, line numbers, conditional ignore parity, and OpenCode .env read guards in one line |
antis-optimizer --handoff --goal "..." |
Creates a compact <= 2 KB JSON checkpoint before context resets |
antis-optimizer --check-update [--critical-only] |
Checks GitHub Releases (read-only; warns on [CRITICAL] fixes without modifying files) |
🔒 Safety & Limits
Built-in guards
- Read-only by default: files change only with
--write (ignore/landmark sync) or --out (handoff).
- Secret redaction on all output: GitHub, OpenAI/Anthropic-style
sk-, Google AIza, AWS AKIA keys and AWS secret access keys (next to an AWS secret key name), Slack, Stripe, npm, GitLab and Hugging Face hf_ tokens, JWTs, PEM private-key blocks, Azure AccountKey= / SharedAccessKey= values, passwords inside scheme://user:pass@host URLs, and quoted values of 8+ characters assigned to password / passwd / secret / api_key / token names (the key name is kept; calls such as getPassword() and text with spaces are left alone).
- Refused files:
.env*, *.pem / *.key / *.p12 / *.pfx, SSH keys, .npmrc, .netrc, .pypirc, .git-credentials, and secret/credential data files.
- Stays inside
--root: paths that escape the repository are refused.
- Never runs code from the scanned repo:
typescript is loaded only from the tool's own install or the global npm dir, never from the repo being scanned. If you copied the script into your own repo and want it to use that repo's typescript, set ANTIS_TRUST_LOCAL_TS=1. Set ANTIS_FORCE_LEXER=1 to skip the compiler entirely.
- Network: only
--check-update goes online, and only to api.github.com.
Measured lexer accuracy
Scored on unmodified real-world files (test/corpus/) against real parsers; CI fails if a score drops. Reproduce with npm run accuracy.
| Language |
Real files |
Symbols |
Exact Lstart-Lend |
Judge |
| Python |
7 |
267 |
100% |
CPython ast |
| JavaScript |
5 |
24 |
100% |
TypeScript compiler |
| TypeScript / TSX |
9 |
145 |
90.3% |
TypeScript compiler |
Every other language in the table above is covered by unit tests only and has no measured accuracy yet. With typescript installed, TS/JS use the compiler itself instead of the lexer.
Known limits
- The built-in lexer is pattern-based, not a full parser. Known TypeScript gaps: arrow functions nested inside functions, overload signatures, and
declare module blocks. Unusual formatting, heavy macros, or generated code can produce a wrong or missing span — check the printed Lstart-Lend before a large edit.
- Redaction is pattern-based. It is a safety net, not a guarantee; keep real secrets out of source files.
- Symbol slices are capped at 120 lines and all output at ~3,500 characters; narrow with a
[filter] or an explicit :Lstart-Lend range.
- Very large repos are scanned up to a visit/depth cap;
--audit prints a partial scan warning when the cap is hit.
Found a security problem? See SECURITY.md.
🤖 Install as an AI Agent Skill
Want your AI assistant to run --audit and wire up projects for you automatically? Clone into your agent's global (or project-local) skills folder: