# lean-context

> Shrink large code files so your AI agent can read them faster and cheaper without losing the important details.

lean-context is a paid AI agent skill on Agensi by Rachid Houmayni, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $12 (one-time purchase)
- Creator: [Rachid Houmayni](https://www.agensi.io/creators/rachid-houmayni)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Version: 1.2
- Last updated: 2026-12-03
- Security: scan passed (2026-10-09); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/lean-context
- Tags: ai-agents, python, token-optimization, claude-code, cursor, ast-parser

## What it does

- Shrinks large Python and TypeScript files by removing code bodies while keeping names and signatures
- Generates a slim directory tree that ignores useless folders like build artifacts and caches
- Summarizes code changes in a repository so you can review updates without reading full files
- Enforces a strict budget to prevent your AI agent from spending too much on a single task
- Triggers a warning if a file is still too large even after it has been compressed

## Who it's for

- **Founders building with AI agents:** Keep your AI sessions running longer without hitting memory limits or high costs. Try: "Analyze my project folder and show me the structure without using too many tokens."
- **Freelance developers and coders:** Review large files and complex codebases without drowning your AI in unnecessary details. Try: "Summarize the functions in this 2,000 line Python file."
- **Product managers reviewing code changes:** Get a clear view of what changed in a project without reading every line of code. Try: "Show me a lean summary of the latest git changes."

## About this skill

When you ask your AI agent to look at a large folder of code, it often gets overwhelmed. It reads too much, forgets earlier instructions, or costs a lot of money because the files are too long. This skill solves that by shrinking what the AI sees. It strips out the "meat" of the code while keeping the "bones" like names and headers. This way, your AI understands the whole project structure without reading every single line.

**How it works**

1. Ask your AI agent to inspect a folder or a specific long file.
2. The skill automatically removes bulky parts of the code while keeping the important labels and signatures.
3. It checks if the result is still too big and asks you before spending too many tokens.
4. Your AI agent gives you a summary or a map of the code that is easy to work with.

**What you get:** A compressed version of your codebase that fits perfectly into your AI agent's memory.

## Requires

- Python

## Known limitations

Supports Python 3.8+ only. Requires python3 on the system PATH. Does not currently support TypeScript, JavaScript, or other languages.

## Technical details

Uses a Python-based AST parser for .py files and a lexer with brace-matching for TS/JS files. It includes a 3,000 token hard budget guard and a Human-in-the-Loop (HITL) trigger. Runs locally via a sidecar script (prune_context.py) with no external API dependencies. Compatible with Claude Code, Cursor, and other agents that support SKILL.md.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the lean-context skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does lean-context achieve 30-50% token savings without losing important code information?

This skill uses Abstract Syntax Tree (AST) parsing to strip boilerplate and internal logic, leaving only class/function signatures and structural skeletons. This allows you to feed your LLM the 'blueprint' of your code rather than the full source, significantly reducing token consumption.

### Does this skill support languages other than Python, such as TypeScript or Go?

Currently, v1.0 is optimized specifically for Python (3.8+). However, the roadmap includes TypeScript and JavaScript support in the upcoming v1.1 release, which will be available to all current license holders.

### Can I use lean-context directly with Claude Code and Cursor?

Yes, lean-context is designed to work seamlessly with CLI-based agents like Claude Code and IDE extensions like Cursor. By running the compression scripts before pasting or piping code into your agent, you stay well within context windows.

### What is the 'budget guard' and how does it prevent unexpected API costs?

The budget guard is a Human-In-The-Loop (HITL) safety feature that prevents accidental token spikes. It enforces a 3,000-token limit per cycle, ensuring your agent doesn't ingest massive amounts of data without your explicit approval.

### What exactly is included in the purchase?

You receive the full suite of AST-aware compression scripts, directory skeleton generators, and git diff summarizers. These are standalone tools with zero external dependencies, making them easy to drop into any Python project.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
