cd /news/ai-agents/i-built-a-cli-harness-that-strips-js… · home › topics › ai-agents › article
[ARTICLE · art-169073] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

I built a CLI harness that strips JS/TS function bodies with Babel AST to save 80% context tokens

Amanulla Shaikh built and open-sourced Apex Agents, a CLI harness that uses Babel's AST parser to strip JavaScript and TypeScript function bodies while preserving types, generics, parameters, and exports, compacting an approximately 13k-token codebase to about 1.4k tokens (88.5% reduction) in testing. The tool also ships a pre-commit hook that blocks AI agents from modifying or skipping tests and halts commits containing high-entropy API keys, 38 specialist persona rules for .cursor/rules, and a native MCP JSON-RPC stdio server for Claude Desktop and Cursor.

by read1 min views11 publishedNov 13, 2026

While working on large Next.js and TypeScript repositories, I noticed AI coding agents (Cursor, Claude Code) constantly burning through context limits. They were reading 500-line implementation files when all they really needed were the types, interfaces, and exported signatures. To solve this mechanically, I engineered and open-sourced Apex Agents.

How It Works:

Babel AST Compactor (npx apex-agents compact): Parses TypeScript, JSX, and JavaScript using @babel/parser and replaces function bodies with {} while preserving all types, generics, parameters, and exports. In our tests, an ~13k token codebase compacted down to ~1.4k tokens (88.5% reduction) into an APEX_CONTEXT.md file.

Pre-Commit Anti-Cheat & Secret Guard (.git/hooks/pre-commit): Diff auditor physically prevents AI agents from modifying or skipping tests to fake a "pass", and halts any accidental commit containing high-entropy API keys.

38 Specialist Personas (.cursor/rules): Injects domain-specific engineering rules directly into .cursor/rules for database performance, React 19 architecture, and Lighthouse optimization.

Native MCP Server:

Built-in JSON-RPC stdio server ready to plug into Claude Desktop or Cursor MCP settings.

Try it in any repo: bash:

npx apex-agents init

GitHub: [github.com/AmanullaShaikh/apex-agents](https://github.com/AmanullaShaikh/apex-agents)

NPM: [npmjs.com/package/apex-agents](https://www.npmjs.com/package/apex-agents)

Feedback and pull requests are welcome!

── more in #ai-agents 4 stories · sorted by recency
── more on @amanulla shaikh 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/i-built-a-cli-harnes…] indexed:0 read:1min 2026-11-13 · —