Vincenzo Petrucci

Founder
Back

Where Context comes from, a CLI tool to create context packs optimized for AI coding

Nowadays, in our industry, all we talk about is AI. Let's set aside for a moment the not-so-subtle difference between vibe coding and AI-assisted coding (which I'd like to discuss in a future article) and focus on how the agents available to us today (Cursor, Claude Code, Codex, etc.) actually work.

When we feed them a task - for example: "The Stripe payment webhook isn't working" - our "assistant" is completely unaware of the project: it doesn't know how it's structured, what technologies it uses, where the files are, which modules are involved. Unless we remembered to create an AGENTS.md (or CLAUDE.md) file with some basic information.

For this reason, often the first thing it does is start grepping: searching for strings in files to find an entry point. Once it finds something promising, it tries to reconstruct the context by following imports, includes, and dependencies.
If the codebase is large, this phase can burn quite a few tokens before even getting to the real work.

But the funny thing is that this procedure, in most cases, can be performed perfectly well without involving AI at all. With a bit of file and symbol indexing, and some heuristics, you can extract from the task an initial context good enough to provide to the assistant, saving it the "effort" of finding it on its own.

That's why I decided to run a small experiment: create a command-line tool that allows you to generate what we might call a context pack, to provide to the AI.

The nice thing is that it doesn't have to be 100% accurate. If the task is too generic and the pack goes off track, the AI is smart enough to figure it out and ignore the useless parts. After all, we humans do the same: if I hand you a folder of files and say "look here", you can quickly tell if it's useful stuff or if I'm wasting your time.

The context pack also has another advantage worth mentioning: it allows you to freeze the project state (at least for the relevant files) before making changes. It can also be useful in the future to reconstruct the reasons behind implementing a feature in a certain way, without having to do archaeology through commits, tickets, Slack messages, and guilt trips.

Ok, so what is a "context pack"?

A context pack is, quite simply, a ready-to-use context package: a curated selection of files, excerpts, and information that help an AI agent work on a specific task without having to waste time getting oriented first.

In my case, the goal was: given a task in natural language (like "fix Stripe webhook"), I want to get an output that:

  • includes the files most likely to be involved

  • brings along some structure (not just a pile of pasted files)

  • is easily "copyable" into a prompt or attachable to an agent

  • is repeatable/deterministic (as much as possible)

And this is where @illegalstudio/context comes in.

context is a CLI tool that works in two main phases:

  1. Indexes the project

  2. Generates a pack based on a task

The idea is: do the heavy lifting once (index), and then generate packs quickly when needed.

Installation:

bash
npm i -g @illegalstudio/context

Or, if you're more of a "I don't install anything globally" person:

bash
npx @illegalstudio/context

How to use it (quick start)

First, index the codebase:

bash
context index

Then generate a pack for a task:

bash
context pack --task "The Stripe payment webhook isn't working"

At that point, you'll find a package in the .context/ folder ready to pass to the agent.

What the pack contains

A pack isn't just "random files": it's a mini-folder containing stuff for both humans and machines.

Typically you'll find:

  • a PACK.md ready to copy into the prompt

  • a TASK.md with analysis and keywords

  • a list of included files (with reasoning/score)

  • useful code excerpts

  • a JSON manifest (for tools/automation)

In practice, it's like saying: "Hey AI, instead of touring around my codebase, here's a map, an itinerary, and tickets already punched".

Oh! If you use Claude Code, Cursor, Codex or any other tool, you can simply ask it: 'In the .context/the-stripe-payment-webhook-isnt-working folder there's a task to complete, start from PACK.md'.

Why a CLI and not a plugin?

Because I wanted something:

  • agnostic (not dependent on Cursor/VSCode/IDE)

  • automatable (scripts, CI, pipelines, etc.)

  • easy to adopt in any project

  • usable even just as a "context documentation generator"

Final thoughts

Obviously, it's not magic. If you describe the task vaguely like "fix bug", don't expect the tool to read your mind.

But in most real cases (bugfixes, targeted features, localized refactors) even a context that's roughly right is already enough to:

  • drastically reduce wasted tokens

  • avoid "generic" responses

  • improve the quality of proposed patches

  • speed up the real work

If you want to learn more about commands, output, and implementation details, you'll find everything in the GitHub repository: https://github.com/illegalstudio/context

© illegal studio 2024 - All rights reserved
P.IVA 02387810688