
Repo Context Builder
- 6 installs
- 5 repo stars
- Updated August 5, 2026
- bjornmelin/dev-skills
Repo-context-builder is a Claude Code skill that builds or refreshes REPO_CONTEXT.md and REVIEW_BRIEF.md from repository evidence.
About
Repo-context-builder is a Claude Code skill that creates or refreshes REPO_CONTEXT.md and REVIEW_BRIEF.md documents for a repository. It inspects manifests, entrypoints, tests, CI, and architecture signals, then writes two high-signal documents so future agents and chats can work without re-discovering the repo. A developer uses it on a new repo, to refresh stale docs, or to produce a grounded task-scoped brief.
- Builds or refreshes REPO_CONTEXT.md and REVIEW_BRIEF.md from repo evidence
- Runs an evidence-first inventory of manifests, entrypoints, tests, and CI
- Leaves a ready-to-paste working prompt for the next agent or chat
Repo Context Builder by the numbers
- 6 all-time installs (skills.sh)
- Ranked #1,205 of 1,879 Documentation skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
repo-context-builder capabilities & compatibility
Free; uses repo files and an optional Python inventory script.
- Capabilities
- repo analysis · documentation generation
- Use cases
- documentation · research · code review
- Pricing
- Free
What repo-context-builder says it does
Create or refresh `REPO_CONTEXT.md` and `REVIEW_BRIEF.md` for the current repository.
The goal is to leave behind two high-signal documents that future agents and chats can use immediately without re-discovering the repository from scratch.
End with a ready-to-paste working prompt for the next agent or chat.
npx skills add https://github.com/bjornmelin/dev-skills --skill repo-context-builderAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 6 |
|---|---|
| repo stars | ★ 5 |
| Last updated | August 5, 2026 |
| Repository | bjornmelin/dev-skills ↗ |
What it does
Generate grounded REPO_CONTEXT.md and REVIEW_BRIEF.md so future agents can act without re-exploring the repo.
Who is it for?
Onboarding a new repo, refreshing stale repo docs, or producing a grounded task-scoped review brief.
Skip if: Writing application code without first producing these context artifacts.
When should I use this skill?
Starting on a new repo, zipping context for later chats, or needing a grounded brief.
What you get
Two high-signal documents, REPO_CONTEXT.md and REVIEW_BRIEF.md, that future agents can use immediately.
- REPO_CONTEXT.md
- REVIEW_BRIEF.md
- ready-to-paste working prompt for the next agent
By the numbers
- 2 output files (REPO_CONTEXT.md, REVIEW_BRIEF.md)
- 5-step required workflow
Files
Create or refresh REPO_CONTEXT.md and REVIEW_BRIEF.md for the current repository.
Keep the workflow evidence-first, compact, and deterministic. The goal is to leave behind two high-signal documents that future agents and chats can use immediately without re-discovering the repository from scratch.
Use bundled resources
Read these files before writing output:
assets/templates/REPO_CONTEXT.mdassets/templates/REVIEW_BRIEF.mdreferences/repo-analysis-playbook.mdreferences/output-checklist.md
Optional helper:
scripts/repo_inventory.pygenerates a fast inventory of the repository. Use it when helpful, but do not rely on it blindly. Verify important claims against the actual files.
Output contract
Produce exactly these files at the repository root unless the user explicitly asks for different paths:
REPO_CONTEXT.mdREVIEW_BRIEF.md
If files already exist, update them in place instead of creating duplicates.
Required workflow
1. Resolve the repository and scope
1. Identify the repository root. 2. Determine whether the repo is a single app, service, library, infra repo, or monorepo. 3. Determine whether the user asked for:
- a full initial intake,
- a refresh of stale repo docs,
- or a task-scoped brief for a specific feature, bug, migration, or review.
4. If the user did not specify a focused task, still create a useful generic REVIEW_BRIEF.md that captures the highest-value next work areas, risks, and recommended entry points.
2. Collect evidence before writing
Inspect the repo in this order:
1. Root signals:
README*AGENTS.md- manifests and lockfiles
- CI config
- container and deployment config
- infra directories
2. Runtime and entrypoints:
- server entry files
- CLI entry files
- app bootstrap files
- job and worker entry files
3. Quality and test signals:
- lint, typecheck, test config
- test directories and representative tests
4. Architecture signals:
- top-level app, package, service, or module folders
- shared libraries
- adapters, API routes, models, schemas, migrations, queues, jobs
5. Operational signals when available:
- deployment workflows
- observability setup
- release or environment docs
6. Git signals when available and useful:
- active branch
- recent commits
- recent changed areas
Use the optional inventory script if it helps accelerate discovery, but confirm important claims by reading the underlying files.
3. Fill REPO_CONTEXT.md
Use the bundled template and replace every placeholder.
Requirements:
- Summarize the repository’s purpose in one tight paragraph.
- Describe the actual architecture, not a guessed ideal architecture.
- Capture exact setup, run, lint, typecheck, test, build, and deploy commands when they are discoverable.
- For monorepos, include the root plus each materially important package or app.
- Include the most important files and why they matter.
- Record risks, tech debt, and open unknowns explicitly.
- Use file paths as evidence anchors throughout.
4. Fill REVIEW_BRIEF.md
Use the bundled template and replace every placeholder.
Requirements:
- Translate the current task into a concise engineering brief.
- Capture in-scope and out-of-scope boundaries.
- List the relevant files, packages, and systems.
- Explain the current state with evidence.
- Identify gaps, risks, and unknowns.
- Propose a concrete implementation or review plan.
- Include an exact verification plan with commands.
- End with a ready-to-paste working prompt for the next agent or chat.
If there is no specific task from the user, make the brief about one of these, in priority order:
1. the most valuable missing capability, 2. the highest-risk weakness, 3. or the highest-leverage cleanup / hardening opportunity.
5. Validate before finishing
Before you stop, verify all of the following:
- Both files exist in the repository root.
- No placeholder markers remain.
- No section is silently omitted. Use
Not found in repoorUnknownwhen necessary. - Commands are copied exactly from the repo when possible, not invented.
- Claims about architecture, deployment, tests, or integrations are backed by file evidence.
- The writing is concise and decision-useful, not bloated.
Evidence rules
- Prefer repository files over assumptions.
- Prefer executable config over prose docs when they disagree.
- Prefer current manifests and CI definitions over stale README instructions.
- Treat generated code, vendored files, and build output as low-trust signals.
- If something cannot be confirmed, label it explicitly as
UnknownorNot found in repo.
Writing rules
- Write for future engineers and future agents.
- Be specific. Name files, directories, commands, workflows, services, and boundaries.
- Keep summaries dense and useful.
- Do not dump giant file trees.
- Do not copy large blocks from README files.
- Do not hallucinate commands, environments, services, secrets, or deployment targets.
- Do not mark something as production-ready unless the repo evidence supports that claim.
Monorepo rules
When the repo contains multiple apps or packages:
- Describe the repo root separately from each important package or app.
- Distinguish shared libraries from deployable services.
- Record package-specific commands when they differ from root commands.
- Call out cross-package dependencies and ownership boundaries when they are inferable.
Missing-information rules
When evidence is incomplete:
- State exactly what was missing.
- State where you looked.
- State the consequence of the missing information.
- Suggest the fastest way to resolve the unknown.
Completion standard
This skill is complete only when a future agent could open the repo with just these two files and quickly understand:
- what the repo is,
- how it is structured,
- how to run and verify it,
- what matters most,
- and how to start the next task safely.
Invocation examples
Explicit invocation is the most reliable way to use this skill.
Example prompts:
$repo-context-builder Analyze this repository and create REPO_CONTEXT.md plus REVIEW_BRIEF.md using the bundled templates.$repo-context-builder Refresh the existing REPO_CONTEXT.md and REVIEW_BRIEF.md after recent changes. Re-check commands, architecture notes, and risks.$repo-context-builder Analyze this repo and create a task-scoped REVIEW_BRIEF.md for the current authentication bug, plus refresh REPO_CONTEXT.md where needed.
interface:
display_name: "Repo Context Builder"
short_description: "Analyze a repository and generate REPO_CONTEXT.md plus REVIEW_BRIEF.md."
default_prompt: "Analyze this repository and create or refresh REPO_CONTEXT.md and REVIEW_BRIEF.md using the bundled templates. Ground every claim in repository evidence and label unknowns explicitly."
policy:
allow_implicit_invocation: false
REPO_CONTEXT
<!-- Fill this document from repository evidence. Replace every placeholder. If a section cannot be completed, write Not found in repo or Unknown. Use file paths as evidence anchors throughout. -->
1. Repository identity
- Repository:
- Primary purpose:
- Repository type: single app | service | library | monorepo | infra | mixed
- Primary languages:
- Primary frameworks / platforms:
- Primary deployment target:
- Default / main branch:
- Root path analyzed:
- Last analyzed:
- Analyzer:
2. One-paragraph summary
Write a tight paragraph explaining what the repository does, who or what it serves, and the main technical shape of the codebase.
3. Top-level layout
| Path | Kind | Role | Notes |
|---|---|---|---|
4. Main runtime surfaces and entrypoints
| Surface | Entrypoint(s) | How it starts | Notes |
|---|---|---|---|
Examples of surfaces:
- web app
- API server
- worker
- CLI
- scheduler / cron job
- shared package with no runtime surface
5. Architecture summary
5.1 Main components
Summarize the important apps, services, packages, layers, or modules.
5.2 Request, job, and data flow
Describe the real flow through the system. Prefer simple prose over diagrams unless the repo already contains a canonical diagram.
5.3 Boundaries and coupling
Note important boundaries, shared libraries, internal APIs, and places where coupling is high.
5.4 External systems and integrations
| System / service | Purpose | Where referenced | Config / secret notes |
|---|---|---|---|
6. Data, state, and contracts
| Concern | Technology / format | Key paths | Notes |
|---|---|---|---|
| Database | |||
| Cache / queue | |||
| Object storage | |||
| Schemas / contracts | |||
| Auth / identity |
Add or remove rows based on the repo.
7. Build, run, and verification workflow
7.1 Prerequisites
List the actual prerequisites discovered in the repo.
7.2 Install / sync
~~~bash
exact commands from repo, if found
~~~
7.3 Run locally
~~~bash
exact commands from repo, if found
~~~
7.4 Lint / format / typecheck / test
~~~bash
exact commands from repo, if found
~~~
7.5 Build / package
~~~bash
exact commands from repo, if found
~~~
7.6 Deploy / release
~~~bash
exact commands from repo, if found
~~~
8. Configuration and secrets
| Variable / file / setting | Required? | Purpose | Evidence |
|---|---|---|---|
9. Testing and quality signals
| Layer | Tooling | Key paths | Notes |
|---|---|---|---|
| Unit | |||
| Integration | |||
| E2E / UI | |||
| Lint / format | |||
| Typecheck |
Adapt rows to the repo.
10. Infrastructure, CI/CD, and operations
10.1 Infrastructure / platform summary
10.2 CI / automation summary
10.3 Observability, logging, and runtime support
10.4 Release / deployment risks
11. Important files to read first
| File | Why it matters |
|---|---|
Keep this list short and high-signal.
12. Current pain points, tech debt, and risks
- - -
13. Change guidance for future agents
List implementation constraints, preferred patterns, and important do-not-break expectations that future work should respect.
- - -
14. Open questions and unknowns
| Item | Why it matters | Where checked | Fastest resolution path |
|---|---|---|---|
15. Evidence log
List the highest-value files that informed this document.
- - -
REVIEW_BRIEF
<!-- Fill this document from the current user request plus repository evidence. If the user did not specify a task, infer the highest-value next task and state that it was inferred. Replace every placeholder. -->
1. Task identity
- Task / feature / problem:
- Desired outcome:
- Status: new | in progress | refresh | inferred from repo
- Priority / urgency:
- Repo / package / area:
- Related issue / PR / branch:
- Prepared on:
- Prepared by:
2. User request or inferred brief
Paste or paraphrase the request concisely. If inferred, say so explicitly.
3. Scope definition
In scope
- -
Out of scope
- -
Assumptions
- -
Constraints
- -
Non-goals
- -
4. Relevant repository context
Key components and systems involved
- -
Relevant files and directories
| Path | Why it matters |
|---|---|
Existing patterns to follow
Describe the implementation patterns, abstractions, conventions, or workflows already present in the repo that should be followed for this task.
5. Current-state findings
| Finding | Evidence | Impact |
|---|---|---|
6. Gaps, risks, and unknowns
| Item | Severity | Why it matters | How to resolve |
|---|---|---|---|
7. Recommended plan
7.1 Implementation or review sequence
1. 2. 3.
7.2 Design decisions
| Decision area | Recommendation | Alternatives considered | Rationale |
|---|---|---|---|
7.3 Files likely to change
| Path | Expected change |
|---|---|
8. Verification plan
Automated checks
~~~bash
exact commands from repo, if found
~~~
Manual / exploratory checks
- -
Rollback or safety checks
- -
9. Deliverables expected from the next working session
- code changes:
- tests:
- docs:
- infra / config:
- PR / handoff notes:
10. Ready-to-paste working prompt for the next session
~~~text Use the attached REPO_CONTEXT.md and REVIEW_BRIEF.md as the source of truth for this repository and task. Re-read the relevant files referenced in both documents before changing code. Then execute the plan in REVIEW_BRIEF.md, keep changes scoped, follow existing repo conventions, update docs/tests as needed, and verify the work with the exact commands listed in the brief before finishing. ~~~
11. Handoff notes
Capture anything a future agent or engineer should know before starting.
- -
Output checklist
Use this checklist before finalizing REPO_CONTEXT.md and REVIEW_BRIEF.md.
Required checks
- Every section in both templates is filled.
- No placeholder text remains.
- Unknowns are labeled explicitly as
UnknownorNot found in repo. - Commands are exact and executable-looking.
- Key claims cite concrete file paths.
- Risks are specific, not generic.
- Monorepo outputs distinguish root concerns from package concerns.
- The brief includes a ready-to-paste working prompt for the next session.
Quality bar for REPO_CONTEXT.md
REPO_CONTEXT.md should answer these questions quickly:
1. What is this repository for? 2. What are the main apps, services, packages, or modules? 3. How do I run, lint, typecheck, test, build, and deploy it? 4. What files should I read first? 5. What risks or unknowns matter right now?
Quality bar for REVIEW_BRIEF.md
REVIEW_BRIEF.md should answer these questions quickly:
1. What is the task? 2. What is in scope and out of scope? 3. Which files and systems matter? 4. What does the repo already do today? 5. What is the recommended next plan? 6. How do I verify the work safely? 7. What prompt should I use next?
Compression rule
Be concise, but not shallow.
Good:
- short tables
- one-paragraph summaries
- explicit file paths
- exact commands
- bullets with decisions and risks
Bad:
- generic narrative
- repeated wording across sections
- giant code excerpts
- giant file trees
- vague advice like "review the backend" or "run tests"
Repo analysis playbook
Use this playbook to gather evidence efficiently and avoid generic repo summaries.
1. Source priority
Trust signals in this order:
1. Executable configuration and code
- manifests
- lockfiles
- CI workflows
- deployment config
- container config
- infra definitions
- entrypoint code
2. Tests and test configuration 3. Repository docs such as README*, docs/, ADRs, specs, runbooks 4. Recent git history and change hotspots 5. Generated artifacts, vendored code, build output, coverage output
If prose and code disagree, prefer the executable source of truth and note the mismatch.
2. Fast scan order
Root-level must-read files
Read what exists:
README*AGENTS.md.env.example,.env.sample,sample.env- manifest files such as
pyproject.toml,package.json,Cargo.toml,go.mod,pom.xml - lockfiles such as
uv.lock,package-lock.json,pnpm-lock.yaml,bun.lock,poetry.lock,Cargo.lock - CI and automation such as
.github/workflows/*,Makefile,justfile,Taskfile.yml - deployment and infra such as
Dockerfile*,compose*.yml,vercel.json,fly.toml,render.yaml,serverless.yml,*.tf,template.yaml,cdk.json
Runtime and architecture files
Look for:
- API and web entrypoints
- CLI entrypoints
- job / worker / scheduler entrypoints
- config loaders
- dependency injection, app factory, or bootstrap code
- routing layers
- service boundaries
- domain models, schemas, migrations, queues, adapters
Quality signals
Look for:
- lint config
- typecheck config
- format config
- test config
- representative tests
- pre-commit hooks or similar enforcement
3. Repo type heuristics
Python repo
Prioritize:
pyproject.tomluv.lock,poetry.lock,requirements*.txtsrc/, package dirs, app entrypoints- pytest config and tests
- ASGI / WSGI / FastAPI / Django / Flask entrypoints
JavaScript / TypeScript repo
Prioritize:
package.json- workspace config such as
pnpm-workspace.yaml,turbo.json,nx.json - build config such as
next.config.*,vite.config.*,tsconfig*.json apps/,packages/,src/- scripts in
package.json
Monorepo
Prioritize:
- root workspace config
- root CI and deployment config
- each deployable app or service
- shared packages used by more than one app
- package-specific run and test commands
4. What to extract for REPO_CONTEXT.md
Always extract these when available:
- repository purpose and product / service role
- main deployable surfaces
- important packages / apps / services
- architecture boundaries and data flows
- local setup and execution commands
- lint / typecheck / test / build commands
- deployment targets and release workflow
- environment and secrets conventions
- integrations and external systems
- operational signals such as logging, metrics, alerts
- important files and directories to read first
- current risks, debt, and unknowns
5. What to extract for REVIEW_BRIEF.md
Always extract these when available:
- the current ask or best inferred next task
- affected code areas and systems
- existing implementation pattern to follow
- current-state findings with evidence
- constraints, assumptions, and non-goals
- concrete plan and file touch list
- verification commands and manual checks
- unresolved questions that block safe implementation
6. Evidence anchor style
Use file paths inline. Good examples:
pyproject.toml.github/workflows/ci.ymlapps/web/package.jsonsrc/api/main.pyinfra/prod/template.yaml
Prefer path-based evidence over vague phrases like "the config" or "the backend".
7. Anti-patterns to avoid
Do not:
- dump the entire tree
- rewrite the README into a new README
- infer architecture from folder names alone
- claim test coverage or deployment health without evidence
- assume a repo is production-ready because deployment files exist
- silently omit missing sections
- invent environment variables, secrets, commands, or ownership
8. Good default when the user did not specify a task
When no specific task is given, choose the most valuable review brief by ranking these:
1. broken or missing verification pipeline 2. unclear or fragile deployment path 3. large architecture risk or cross-cutting debt 4. missing docs that block future work 5. highest-leverage next feature clearly implied by the repo
State that the brief is inferred from repository evidence.
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import json
import os
from collections import Counter, defaultdict
from dataclasses import dataclass
from pathlib import Path
from typing import Iterable
IGNORE_DIRS = {
".git",
".hg",
".svn",
".idea",
".vscode",
".venv",
"venv",
"node_modules",
"dist",
"build",
".next",
".nuxt",
".turbo",
".cache",
"coverage",
"htmlcov",
"target",
"out",
"__pycache__",
".pytest_cache",
".mypy_cache",
".ruff_cache",
".tox",
".pnpm-store",
}
SPECIAL_FILENAMES = {
"Dockerfile": "docker",
"docker-compose.yml": "compose",
"docker-compose.yaml": "compose",
"Makefile": "make",
"justfile": "just",
"Procfile": "procfile",
}
EXTENSION_LANG = {
".py": "Python",
".pyi": "Python",
".ts": "TypeScript",
".tsx": "TypeScript",
".js": "JavaScript",
".jsx": "JavaScript",
".mjs": "JavaScript",
".cjs": "JavaScript",
".json": "JSON",
".jsonc": "JSON",
".toml": "TOML",
".yaml": "YAML",
".yml": "YAML",
".md": "Markdown",
".sql": "SQL",
".sh": "Shell",
".bash": "Shell",
".zsh": "Shell",
".ps1": "PowerShell",
".go": "Go",
".rs": "Rust",
".java": "Java",
".kt": "Kotlin",
".swift": "Swift",
".rb": "Ruby",
".php": "PHP",
".c": "C",
".h": "C",
".cpp": "C++",
".hpp": "C++",
".cs": "C#",
".tf": "Terraform",
".tfvars": "Terraform",
}
KEY_FILE_PATTERNS = {
"readme": ["README", "README.md", "README.rst"],
"agents": ["AGENTS.md", "AGENTS.override.md"],
"python": ["pyproject.toml", "uv.lock", "requirements.txt", "requirements-dev.txt", "setup.py"],
"javascript": ["package.json", "pnpm-lock.yaml", "package-lock.json", "bun.lock", "bun.lockb", "turbo.json", "nx.json"],
"rust": ["Cargo.toml", "Cargo.lock"],
"go": ["go.mod", "go.sum"],
"docker": ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"],
"ci": [".github/workflows"],
"infra": ["template.yaml", "serverless.yml", "serverless.yaml", "cdk.json", "vercel.json", "fly.toml", "render.yaml", "render.yml"],
}
ENTRYPOINT_HINTS = {
"main.py",
"app.py",
"server.py",
"manage.py",
"asgi.py",
"wsgi.py",
"cli.py",
"index.ts",
"index.tsx",
"index.js",
"main.ts",
"main.tsx",
"main.js",
}
@dataclass
class Inventory:
root: Path
total_files: int
total_dirs: int
languages: dict[str, int]
top_level_dirs: list[str]
key_files: dict[str, list[str]]
entrypoints: list[str]
tests: list[str]
workflows: list[str]
def should_skip_dir(dirname: str) -> bool:
return dirname in IGNORE_DIRS or dirname.startswith(".ruff_cache")
def detect_language(path: Path) -> str | None:
if path.name in SPECIAL_FILENAMES:
return SPECIAL_FILENAMES[path.name]
return EXTENSION_LANG.get(path.suffix.lower())
def walk_repo(root: Path) -> tuple[list[Path], list[Path]]:
dirs: list[Path] = []
files: list[Path] = []
for current, dirnames, filenames in os.walk(root):
dirnames[:] = [d for d in dirnames if not should_skip_dir(d)]
current_path = Path(current)
dirs.extend(current_path / d for d in dirnames)
files.extend(current_path / f for f in filenames)
return dirs, files
def relative_paths(paths: Iterable[Path], root: Path) -> list[str]:
return sorted(str(p.relative_to(root)).replace("\\", "/") for p in paths)
def collect_key_files(files: list[Path], root: Path) -> dict[str, list[str]]:
rels = relative_paths(files, root)
found: dict[str, list[str]] = defaultdict(list)
for rel in rels:
name = Path(rel).name
for category, patterns in KEY_FILE_PATTERNS.items():
for pattern in patterns:
if rel == pattern or name == pattern or rel.startswith(f"{pattern}/"):
found[category].append(rel)
return {k: sorted(v) for k, v in found.items()}
def collect_entrypoints(files: list[Path], root: Path) -> list[str]:
rels = relative_paths(files, root)
matches: list[str] = []
for rel in rels:
path = Path(rel)
if path.name in ENTRYPOINT_HINTS:
matches.append(rel)
continue
lowered = rel.lower()
if any(token in lowered for token in ["/api/", "/cli/", "/worker", "/jobs/", "/cmd/"]):
if path.suffix.lower() in {".py", ".ts", ".tsx", ".js", ".go", ".rs"}:
matches.append(rel)
return sorted(set(matches))[:40]
def collect_tests(files: list[Path], root: Path) -> list[str]:
rels = relative_paths(files, root)
test_files = [
rel
for rel in rels
if "/tests/" in f"/{rel}" or Path(rel).name.startswith("test_") or Path(rel).name.endswith(".test.ts") or Path(rel).name.endswith(".spec.ts") or Path(rel).name.endswith(".spec.tsx") or Path(rel).name.endswith(".test.tsx") or Path(rel).name.endswith(".test.js") or Path(rel).name.endswith(".spec.js")
]
return sorted(test_files)[:60]
def collect_workflows(files: list[Path], root: Path) -> list[str]:
rels = relative_paths(files, root)
workflows = [rel for rel in rels if rel.startswith('.github/workflows/')]
return sorted(workflows)
def make_inventory(root: Path) -> Inventory:
dirs, files = walk_repo(root)
lang_counter: Counter[str] = Counter()
for file in files:
language = detect_language(file)
if language:
lang_counter[language] += 1
top_level_dirs = sorted(
p.name for p in root.iterdir() if p.is_dir() and not should_skip_dir(p.name)
)
return Inventory(
root=root,
total_files=len(files),
total_dirs=len(dirs),
languages=dict(lang_counter.most_common()),
top_level_dirs=top_level_dirs,
key_files=collect_key_files(files, root),
entrypoints=collect_entrypoints(files, root),
tests=collect_tests(files, root),
workflows=collect_workflows(files, root),
)
def render_markdown(inventory: Inventory) -> str:
lines: list[str] = []
lines.append("# Repository inventory")
lines.append("")
lines.append(f"- Root: `{inventory.root}`")
lines.append(f"- Total files scanned: {inventory.total_files}")
lines.append(f"- Total directories scanned: {inventory.total_dirs}")
lines.append("")
lines.append("## Languages by file count")
lines.append("")
lines.append("| Language | Files |")
lines.append("| --- | ---: |")
for language, count in inventory.languages.items():
lines.append(f"| {language} | {count} |")
if not inventory.languages:
lines.append("| Unknown | 0 |")
lines.append("")
lines.append("## Top-level directories")
lines.append("")
for dirname in inventory.top_level_dirs[:50]:
lines.append(f"- `{dirname}/`")
if not inventory.top_level_dirs:
lines.append("- None")
lines.append("")
lines.append("## Key files by category")
lines.append("")
for category, paths in sorted(inventory.key_files.items()):
lines.append(f"### {category}")
lines.append("")
for rel in paths[:40]:
lines.append(f"- `{rel}`")
if not paths:
lines.append("- None")
lines.append("")
if not inventory.key_files:
lines.append("No key files matched the built-in heuristics.")
lines.append("")
lines.append("## Entrypoint candidates")
lines.append("")
for rel in inventory.entrypoints:
lines.append(f"- `{rel}`")
if not inventory.entrypoints:
lines.append("- None found by heuristic")
lines.append("")
lines.append("## Test files")
lines.append("")
for rel in inventory.tests:
lines.append(f"- `{rel}`")
if not inventory.tests:
lines.append("- None found by heuristic")
lines.append("")
lines.append("## CI workflows")
lines.append("")
for rel in inventory.workflows:
lines.append(f"- `{rel}`")
if not inventory.workflows:
lines.append("- None found")
lines.append("")
return "\n".join(lines)
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Generate a fast repository inventory for repo analysis.")
parser.add_argument("--root", default=".", help="Repository root to scan. Defaults to current directory.")
parser.add_argument("--format", choices=["markdown", "json"], default="markdown")
parser.add_argument("--out", default="", help="Optional output file path.")
return parser.parse_args()
def main() -> int:
args = parse_args()
root = Path(args.root).resolve()
inventory = make_inventory(root)
if args.format == "json":
payload = json.dumps(inventory.__dict__, indent=2, default=str)
else:
payload = render_markdown(inventory)
if args.out:
output_path = Path(args.out)
output_path.write_text(payload, encoding="utf-8")
else:
print(payload)
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
FAQ
What files does repo-context-builder produce?
It produces REPO_CONTEXT.md and REVIEW_BRIEF.md at the repository root, updating them in place if they already exist.
Does it handle monorepos?
Yes, it describes the repo root separately from each important package or app and records package-specific commands.