Codebase Clarity is a TypeScript CLI that explains a local codebase in plain English. Point it at a project directory and it writes a readable architecture report that covers the main languages, framework signals, module areas, notable files, imports, and exports.
It is meant to help people understand an unfamiliar repo before they edit it, review it, document it, or hand it to another maintainer.
- Developers joining a project who need a quick map of the code.
- Maintainers preparing a handoff, audit, or cleanup plan.
- Reviewers who want a neutral summary before reading a large diff.
- Technical leads comparing project structure across multiple repos.
- Non-specialist stakeholders who need a plain-English explanation of what a codebase contains.
Codebase Clarity does not execute the target project. It reads files from disk and summarizes signals that are usually available from source text and project metadata:
- It recursively walks the target directory.
- It skips common generated, dependency, cache, and local-agent folders such as
node_modules,dist,.git,.cache,.codex,AGENTS.md, andObsidian. - It keeps relevant source, config, manifest, lockfile, and documentation files within the scan limits.
- It detects languages from file extensions and important filenames.
- It detects framework signals from config files, imports, and dependency names in
package.json. - It groups files into plain-English module areas from top-level folders and known project conventions.
- It renders a report to stdout or to a file.
flowchart LR
User[User chooses target repo] --> CLI[CLI parses options]
CLI --> Walker[Safe file walker]
Walker --> Filters[Ignore generated and local-only paths]
Filters --> Signals[Detect languages frameworks imports exports]
Signals --> Modules[Group files into module areas]
Modules --> Report[Plain-English architecture report]
Report --> Output[Stdout or output file]
Requirements:
- Node.js 20.19 or newer.
- npm 11 or newer is recommended for the lockfile and audit commands used by this repo.
Install and build:
npm ci
npm run buildRun the built CLI against the current directory:
node dist/cli.jsRun it against another project and write the report to a file:
node dist/cli.js ../some-project --output architecture-report.txtLimit scan size for large repos:
node dist/cli.js ./project --max-files 250 --max-file-size-kb 128Show help and version:
node dist/cli.js --help
node dist/cli.js --versionnpm run lint
npm test
npm run build
npm run audit:moderate
npm run deps:outdated
npm run checkCommand purpose:
npm run lintchecks TypeScript source and tests with ESLint.npm testruns the Vitest test suite.npm run buildcompilessrcintodistand writes type declarations.npm run audit:moderatefails on moderate-or-higher npm advisories.npm run deps:outdatedfails when npm reports outdated dependencies.npm run checkruns lint, tests, build, audit, and outdated checks in one command.
The CLI is configured with command-line flags. It does not require secrets or external service credentials.
Use .env.example as a safe template for local shell wrappers or CI variables:
CODEBASE_CLARITY_TARGET=.
CODEBASE_CLARITY_OUTPUT=architecture-report.txt
CODEBASE_CLARITY_MAX_FILES=500
CODEBASE_CLARITY_MAX_FILE_SIZE_KB=256These values mirror the CLI concepts:
CODEBASE_CLARITY_TARGETis the directory to scan.CODEBASE_CLARITY_OUTPUTis an optional report file path.CODEBASE_CLARITY_MAX_FILESmaps to--max-files.CODEBASE_CLARITY_MAX_FILE_SIZE_KBmaps to--max-file-size-kb.
.
|-- .github/
| |-- dependabot.yml
| `-- workflows/ci.yml
|-- src/
| |-- cli.ts
| |-- index.ts
| |-- report.ts
| |-- scanner.ts
| `-- types.ts
|-- tests/
| |-- cli.test.ts
| |-- report.test.ts
| `-- scanner.test.ts
|-- .env.example
|-- eslint.config.js
|-- package.json
|-- README.md
|-- tsconfig.json
`-- vitest.config.ts
Important areas:
src/cli.tsparses command-line flags, runs scans, and writes output.src/scanner.tswalks files, ignores generated paths, extracts imports and exports, and detects framework signals.src/report.tsturns scan data into a plain-English report.src/types.tsdefines the scan and report data shapes.tests/covers CLI parsing, scanning behavior, and report rendering..github/workflows/ci.ymlruns dependency hygiene, linting, tests, and build checks..github/dependabot.ymlasks Dependabot to keep npm packages and GitHub Actions current.
- Codebase Clarity scans local files only and does not send code to a network service.
- It does not execute the target project.
- It skips common generated folders, dependency folders, VCS metadata, and local-agent notes by default.
- Reports can include filenames, dependency names, imports, exports, and project structure. Review reports before sharing them publicly.
- Do not put secrets in
.env.example, README examples, reports, test fixtures, or committed config. - Keep private notes and machine-specific files out of version control.