SuperAPI AI Directory

llm-context.py

llm-context.py is a tool for sharing code context with large language models, supporting content transfer via the Model Context Protocol (MCP) or the clipboard. It allows rule-based customization for easy switching between different tasks (such as code review and documentation writing), and includes a smart code outlining feature. The tool provides commands such as lc-init, lc-preview, lc-context, lc-missing, lc-changed, and lc-outlines, helping developers prepare focused code context for coding agents or chat models.

Open website

About this tool

Purpose

llm-context.py is designed to solve the friction involved in getting the right context into a large language model: manually finding and copying files is time-consuming, too much context hits token limits, too little misses key information, and subsequent file requests require manual retrieval again. The tool selects files through rule description files, lets the agent write, validate, and reuse rules on its own, and the tool handles packaging, follow-up retrieval, and change tracking.

Main capabilities

  • Supports sharing code with an LLM via the Model Context Protocol (MCP) or the clipboard.
  • Rule-based customization for easy switching between different tasks (such as code review and documentation writing).
  • Includes smart code outlining.
  • Provides the lc-init installation skill, teaching the agent to determine the files needed for a task, write them as composable rules, check the rules against the codebase, and package the result—for its own context, pasting into chat, or dispatching to a subagent.
  • lc-preview reports the exact file list, sizes, and shows via the code graph the files defining symbols that were selected for use but not included, helping the agent spot missing modules before wasting a round on a wrong answer.
  • Provides commands such as lc-missing, lc-changed, lc-outlines, and lc_preview, supporting the model in pulling files it was not given and noticing changes beneath them.
  • Rules consist of YAML frontmatter plus optional markdown. Rules are composable and named by category: prm- generates context, flt- controls file inclusion, ins- provides guidance, sty- enforces coding standards, exc- configures excerpts. Files expected to be edited go into full-files; supporting code goes into excerpted-files, reduced to signatures and definitions.
  • The generated context includes: the full contents of full-text files, structural excerpts of the remaining files, a marked list of included and excluded filtered files, and a timestamp for lc-missing and lc-changed to parse.
  • The header reports the counts of full, outlined, and excerpted files, so consumers can check what they actually received rather than trusting the rules.

Usage

Three usage paths:

  1. Coding agent self-curation—the primary path. After running lc-init, the agent gains the lc-curate-context skill, and can write and validate rules without the user specifying files.
  2. Subagent viaThrough the pipeline — the dispatcher writes the prompt, llm-context provides the files. Use -r to route output to stdout; without -r, lc-context copies to the clipboard, and piping or redirecting only yields log lines. These commands do not accept bare positional rule names; always use -r. -a renders the fetch instructions in the package as shell commands for a subprocess to run itself, so from the repository root lc-missing can be invoked to fetch missing content based on the package's timestamps.
  3. Chat via MCP or clipboard — for models that do not drive a terminal. With MCP, the model pulls files it was not given via lc_missing, lc_changed, lc_outlines, and lc_preview and notices changes beneath them. Without MCP, lc-select then lc-context puts the package on the clipboard, ready to paste anywhere.

Upgrading: uv tool upgrade llm-context, then any lc-* command refreshes skills, rules, and templates in place.

Documentation lives in the lc-curate-context skill, installed into the project by lc-init for agents to read. After installation, find it at .claude/skills/lc-curate-context/. In Claude Code the skill loads automatically; elsewhere, read the files directly.

When to use

  • Code review: prepare focused code context for a review task.
  • Documentation writing: prepare relevant files for documentation generation.
  • Coding agents autonomously curating context: let the agent determine the files needed for the task itself and package them.
  • Dispatching subagents: the dispatcher writes the prompt, the tool provides the files.
  • Chatting with models that do not drive a terminal: share code via MCP or clipboard.

Limitations

  • The package is always partial — the file list is filtered by .gitignore files and rules before exclusions are marked, so files may exist that are never mentioned.
  • Commands do not accept bare positional rule names; -r must be used to route output to stdout, otherwise output goes to the clipboard.
  • Full documentation is only in the lc-curate-context skill; the README is not a manual.
  • Other specific limitations are not provided for now.