Turn your entire repository into one clean Markdown file your AI coding agent can actually read.
Stop copy-pasting files into ChatGPT one at a time. repo-context scans your repo, respects your .gitignore, and writes a single context.md with an overview, a directory tree, and the full contents of every relevant file β ready to paste into Claude, ChatGPT, Cursor, Copilot, or any LLM that needs to understand your project fast.
- Zero config, sensible defaults β just run it, it figures out what matters.
- Git-aware β uses
git ls-filesunder the hood so anything in.gitignoreis automatically skipped. - Monorepo friendly β picks up every
package.jsonin the tree for a quick multi-package overview. - Binary-safe β skips images, fonts, archives, and lockfiles instead of dumping garbage into your context window.
- Budget aware β caps individual file size and total embedded size so you don't blow your model's context window.
- Fast β plain Node.js, no heavy dependencies, runs in milliseconds on most repos.
Run it once, no install required:
npx @krizic/repo-contextThat's it β you now have a context.md in your project root. Drop it into your favorite AI chat and start asking questions about your codebase.
npm install --save-dev @krizic/repo-context
# or
pnpm add -D @krizic/repo-context
# or
yarn add -D @krizic/repo-contextThe nicest way to use repo-context is to wire it into package.json so your whole team (and every agent) can run it the same way:
Then simply run:
npm run context| Flag | Default | Description |
|---|---|---|
--out <path> |
context.md |
Where to write the generated file (relative to --root). |
--root <path> |
current directory | Repository root to scan. |
--max-bytes <n> |
100000 |
Max size (bytes) of a single file's content to embed. Larger files are listed but skipped. |
--max-total-bytes <n> |
5000000 |
Total size (bytes) budget for all embedded file contents combined. |
--tree-only |
false |
Only emit the overview + directory tree, skip embedding file contents entirely. |
README.md, AGENTS.md, AGENT.md, CONTRIBUTING.md, and ARCHITECTURE.md are always embedded in full, regardless of size limits, since they're usually the most useful context for an agent.
Prefer to script it yourself? repo-context exports its core function too:
import { generateContext } from '@krizic/repo-context'
const result = await generateContext({
root: process.cwd(),
out: 'CONTEXT.md',
maxFileBytes: 50_000
})
console.log(result.stats)# Repository Context: my-app
_Generated: 2026-07-24T10:00:00.000Z_
## Overview
- **my-app** (package.json) β v1.0.0
- scripts: build, dev, test
## Directory Structure
βββ src/
β βββ index.ts
β βββ utils.ts
βββ package.json
## File Contents
### src/index.ts
β```ts
...
β```
## Stats
- Files listed: 42
- Files embedded: 38 (210.4 KB)
- Skipped (binary): 3
- Skipped (over --max-bytes): 1Issues and PRs are very welcome! This is a small, focused tool β the best contributions keep it that way.
git clone https://github.com/krizic/repo-context.git
cd repo-context
npm install
npm run build
npm testMIT Β© Vedran Krizic
{ "scripts": { "context": "repo-context", // override the defaults to fit your project "context:full": "repo-context --out docs/context.md --max-bytes 200000 --max-total-bytes 20000000", // just want the shape of the repo, no file contents? "context:tree": "repo-context --tree-only --out docs/tree.md" } }