repobrief-cli
v0.1.1
Published
Generate a structured, token-conscious Markdown brief of a repository for AI coding assistants.
Maintainers
Readme
RepoBrief
Give your AI the context it needs.
RepoBrief analyzes a local repository and generates a structured, token-conscious Markdown brief: project overview, technology stack, directory structure, entry points, development commands, conventions and a prioritized selection of source files. Hand it to Claude Code, Cursor or any other LLM tool so it understands your codebase before it changes anything.
It does not dump every file into one huge prompt. It picks the most useful files first, stays within a size limit, and leaves secrets out.
- Runs entirely locally. No account, server, API key or network requests.
- Zero runtime dependencies. Node.js 20+.
- Never modifies your source files.
Repository: github.com/Sameera-MHK/repo-brief · Owner: sameera_mhk
Installation
npm install -g repobrief-cliOr run it without installing:
npx repobrief-cli generate .Quick start
cd my-project
repobrief analyze . # quick terminal summary
repobrief generate . # writes ./repobrief.mdThen give repobrief.md to your AI assistant, for example: "Read repobrief.md before making changes."
Example generated brief
# Repository Brief: sample-app
> Generated by RepoBrief. Read this brief first, then inspect the original source files before making changes.
## Project Overview
**Description (package.json):** A sample Express app
**Package:** `sample-app` (version 1.2.3)
**From README.md:** Sample app that serves a small API.
**Files:** 9 found, 7 eligible, 2 excluded, 7 included below.
## Technology Stack
- **Languages (by file extension):** JavaScript (4), JSON (1), Markdown (1), Shell (1)
- **Frameworks:** Express (package.json dependencies)
- **Testing:** Vitest (package.json devDependencies)
## Directory Structure
...
## Architecture and Entry Points
**Confirmed** (declared in configuration):
- `src/server.js` — package.json "main"
**Inferred** (from file names and locations; verify before relying on them):
- `src/routes/users.js` — possible route or API handler (path naming)
## Development Commands
- `npm run start` — `node src/server.js`
## Important Files
## Coding Conventions
## Source Context
## AI Assistant InstructionsCommands
repobrief generate [path]
Analyzes the repository at path (default .) and writes a brief. The default output is repobrief.md inside the target directory (repobrief.json with --json).
repobrief analyze [path]
Prints a concise summary: project name, languages, frameworks, important dependencies, repository/selected/excluded file counts, approximate output size and detected entry points. Add --json for machine-readable output.
Options
| Flag | Description |
| --- | --- |
| -o, --output <path> | Output file location. |
| --max-files <n> | Maximum number of source files to include (default 50). |
| --max-chars <n> | Maximum total generated characters (default 200000). |
| --include <glob> | Only include matching files. Repeatable. |
| --exclude <glob> | Exclude matching files or directories. Repeatable. |
| --dry-run | Show the planned analysis and file selection without writing output. |
| --json | Output structured JSON instead of Markdown. |
| --force | Overwrite an existing RepoBrief output file. |
| -h, --help | Show usage. |
| -v, --version | Show the package version. |
Examples:
repobrief generate . --max-files 20 --max-chars 80000
repobrief generate . --include "src/**" --exclude "**/*.test.js"
repobrief generate ../other-repo --output ./other-brief.md
repobrief generate . --dry-runExit codes
| Code | Meaning |
| --- | --- |
| 0 | Success. |
| 1 | Completed, but an error occurred (for example, unreadable files or a failed write). |
| 2 | Invalid arguments, invalid target or configuration error (for example, unsafe output path). |
Warnings (such as a file excluded for a possible secret) are printed to stderr prefixed with warning: and do not change the exit code. Errors are prefixed with error:.
How files are selected
Files are ordered deterministically by priority, then by directory depth, then by path:
- Project configuration (
package.json,tsconfig.json, linter/formatter and build configs, ...) - README and architecture/documentation files
- Application entry points (
main,bin,exportsinpackage.json, or files such asindex.js,main.js,server.jsnear the root) - Route definitions and API handlers (
routes/,api/,controllers/,handlers/, ...) - Shared modules (
lib/,utils/,shared/,services/, ...) - Remaining text files
Whole files are added in that order until --max-files or --max-chars is reached; then selection stops. Files are never truncated. Files left out are listed in an Omitted Files notice in the brief.
Size reporting shows the exact character count and an approximate token count, estimated as characters / 4. RepoBrief does not ship a tokenizer, so the real token count for your model will differ.
Ignore configuration
RepoBrief combines these rules:
.gitignorefiles (root and nested), using familiar gitignore syntax..repobriefignorein the repository root, same syntax. Use it for files that are in git but not useful as AI context:# .repobriefignore docs/legacy/ *.snap fixtures/**/*.json--include/--excludepatterns from the command line. When--includeis used, only matching files are considered.Built-in exclusions:
- Directories:
node_modules,.git,dist,build,coverage,.next,.nuxt,vendor,.cache, plus a few other common build and cache folders. - Binary files (by extension or content), and files larger than 100 KB.
- Lockfiles (
package-lock.json,yarn.lock,pnpm-lock.yaml, ...) unless matched by--include. - Generated output (
repobrief.md,repobrief.json, any previous brief) and the output file itself.
- Directories:
Supported pattern syntax: *, **, ?, [...], leading / to anchor to the root, trailing / for directories, and ! to re-include.
Privacy and secret protection
- RepoBrief never sends repository content anywhere. It makes no network requests and uses only Node.js filesystem APIs (no shell commands).
- Sensitive files are always excluded:
.envand.env.*, private keys and certificates (*.pem,*.key,*.p12,id_rsa, ...), and credential files (credentials.json,.npmrc,.netrc, ...). - Every file is checked for common secret patterns (private key blocks, AWS, GitHub, Slack, Stripe, Google, npm and OpenAI-style keys, and long literal values assigned to names like
API_KEY,tokenorpassword). If a match is found, the entire file is excluded. - Secret values are never printed in warnings, errors or JSON output — only the file path and "possible secret detected".
- Symlinks pointing outside the repository are not followed; symlinked directories are skipped.
Pattern-based detection cannot catch every secret. Review the generated brief before sharing it.
Output safety
- RepoBrief only writes the single output file. It never edits source files or AI assistant configuration files.
- It refuses to overwrite a file in the repository that is not a previous RepoBrief output.
- Replacing an existing brief requires
--force. - The default output location is the target directory; any other location must be passed explicitly with
--output, and its directory must already exist.
Limitations
- Framework and tool detection is based on
package.json(andrequirements.txt/pyproject.tomlfor a few Python frameworks). Other ecosystems get language and file-structure detection only. - Entry point and route detection outside
package.jsonis inferred from file names and paths and is labelled as inferred. - Gitignore support covers common syntax but not every edge case of git's implementation; global git excludes are not read.
- Files larger than 100 KB are skipped rather than partially included.
- Token counts are estimates.
Contributing
Contributions are welcome. Please open an issue or pull request at github.com/Sameera-MHK/repo-brief.
git clone [email protected]:Sameera-MHK/repo-brief.git
cd repo-brief
npm test
node bin/repobrief.js analyze .- Keep the dependency footprint at zero unless there is a strong reason.
- Add tests for new behaviour; tests create temporary repositories in
test/helpers.js. - Keep output evidence-based: don't report a framework or convention without a file that supports it.
Author
Maintained by sameera_mhk (@Sameera-MHK).
License
MIT © sameera_mhk
