primer-ai
v0.1.87
Published
Beta CLI that scaffolds AI-optimized project architecture for Codex and Claude Code.
Maintainers
Readme
primer-ai
primer-ai is a beta TypeScript CLI for four jobs:
- bootstrap a repository with AI-ready project architecture and maintainable agent context
- run AI-guided refactors on existing codebases using your locally installed agent CLI
- run AI-guided verification/fix loops that detect and remediate actionable repo issues
- generate GitHub-style release log notes from previous version/tag to current state
The project started from deep research across modern AI workflows (including ChatGPT and Claude research tooling) to capture practical patterns that are usually missing when teams run ad-hoc /init prompts.
Why This Exists
Most AI coding sessions are stateless and inconsistent across runs. primer-ai creates explicit project context surfaces so assistants can work from shared, versioned rules:
- root + scoped
AGENTS.mdinstruction chain docs/knowledge base (architecture, contracts, runbooks, ADRs)skills/catalog with trigger tests- maintenance checks that keep instructions and docs fresh over time
It also includes refactor and fix workflows for medium and large repositories, with resumable multi-pass refactor execution and Codex orchestration support.
Current Status
- Release channel:
beta - Recommended and best-tested path: Codex CLI
- Claude Code path: implemented, but less battle-tested
- Platform testing status: verified primarily on macOS
- Linux/Windows: expected to work for many cases, but currently less validated
What It Generates
init scaffolding produces:
AGENTS.md+ scoped instruction files.agents/fragments/root/*composition fragmentsdocs/source-of-truth docs, ADRs, and runbook structure- optional Claude artifacts (
CLAUDE.md,.claude/rules/,.claude/settings.json) - optional Cursor rules (
.cursor/rules/) - maintenance scripts:
scripts/check-agent-context.mjsscripts/check-doc-freshness.mjsscripts/check-skills.mjsscripts/doc-garden.mjs
- GitHub workflows for context checks and doc gardening
Requirements
- Node.js
>= 20.10.0 - npm
- Git
- Optional AI CLIs:
codex(recommended)claude(supported fallback path)
init --mode template works without AI CLIs.
init --mode ai-assisted, refactor, fix, and generate-logs require an installed and authenticated AI CLI.
Install and Use
Run without installing (always uses latest published version):
npx primer-ai@latest --helpInstall globally:
npm i -g primer-ai
primer-ai --helpCheck installed version:
primer-ai --versionQuick Start
Initialize in the current directory:
npx primer-ai initInitialize a target directory:
npx primer-ai init my-new-projectInitialize non-interactively with explicit settings:
npx primer-ai init . \
--yes \
--description "Internal analytics API for event ingestion" \
--stack "TypeScript + Node.js + PostgreSQL" \
--project-type api-service \
--agent codex \
--mode ai-assisted \
--provider codexRun refactor in the current repo:
npx primer-ai refactor . --provider autoRun scan-only dry run:
npx primer-ai refactor . --dry-runRun AI-assisted fix loop (detect verification failures, apply fixes, re-check):
npx primer-ai fix . --provider autoGenerate release logs in GitHub markdown style:
npx primer-ai generate-logs .Generate release logs between two versions (even if current HEAD is newer):
npx primer-ai generate-logs . --from-version 0.1.59 --to-version 0.1.79Refactor Workflow
In interactive terminals, refactor does:
- scan repository and build backlog
- collect execution choices (provider/model/logging/notes/orchestration)
- run AI passes
- print deterministic summary (passes, backlog, file changes, verification notes)
Checkpointing:
- Saved at
.primer-ai/refactor-resume.json - By default
--resumeis enabled - Interrupted runs can continue from the last saved pass
Codex orchestration:
- Enabled by default (
--orchestration) - Planner / orchestrator / worker role models are supported
- Default role models:
- planner:
gpt-5.3-codex - orchestrator:
gpt-5.3-codex - worker:
gpt-5.3-codex-spark
- planner:
--max-subagentsrange:1..24(default12)
Quick Setup Presets (init --quick-setup)
Available in AI-assisted mode for supported stacks:
- Next.js + TypeScript (
nextjs-ts) - React + Vite + TypeScript (
vite-react-ts) - TypeScript + Node.js (
node-ts) forapi-service,cli-tool,library,custom - Swift + SwiftPM (
swift-spm) forapi-service,cli-tool,library,custom
Not enabled yet:
- monorepo quick setup
- Swift/iOS (Xcode) quick setup
Command Reference
primer-ai init [path]
Purpose:
- scaffold AI-optimized project structure
- for non-empty repositories, migration is supported only in
ai-assistedmode
Options:
--description <text>project description--stack <text>tech stack summary--project-type <type>web-app | api-service | library | cli-tool | monorepo | custom--agent <target>codex | claude | both(defaultcodex)--mode <mode>template | ai-assisted(defaultai-assisted)--provider <provider>auto | codex | claude--model <model>model id when provider is fixed (codexorclaude)--cursor/--no-cursorgenerate.cursor/rules(defaultfalse)--git-init/--no-git-initinitialize Git if missing (defaulttrue)--quick-setuprun supported quick setup after scaffold (defaultfalse)--format <format>text | json(controls error output format)-y, --yesskip prompts and use defaults--forceoverwrite existing scaffold paths instead of creating.primer-ai.generatedvariants
primer-ai refactor [path]
Purpose:
- scan repository
- calibrate backlog
- execute adaptive AI refactor passes with optional orchestration
Options:
--provider <provider>auto | codex | claude(defaultauto)--model <model>model id when provider is fixed--planner-model <model>planner model for Codex orchestration--orchestrator-model <model>orchestrator model for Codex orchestration--worker-model <model>worker model for Codex orchestration--agent <target>codex | claude | both(used with--provider auto)--notes <text>custom notes for scan/refactor prompt--focus <text>merged into notes--show-ai-file-ops/--no-show-ai-file-opsstream compact AI file-operation events (defaulttrue); known noisy provider internals and prompt-echo text are suppressed, and file ops are shown as conciseRead/Created/Updated/Deleted filelines--orchestration/--no-orchestrationCodex orchestration toggle (defaulttrue)--max-subagents <count>orchestration workers1..24(default12)--max-files <count>scan file cap (default auto)--max-passes <count>pass cap (default adaptive)--ai-timeout-sec <seconds>timeout per AI subprocess (default1800, clamped to60..14400)--format <format>text | json(controls error output format)--resume/--no-resumecheckpoint behavior (defaulttrue)--dry-rungenerate prompt only, no AI execution-y, --yesnon-interactive execution choices
primer-ai fix [path]
Purpose:
- detect verification failures based on stack policy, scripts, and installed package tooling
- run iterative AI fix passes and re-run checks until actionable failures clear or pass cap is reached
Options:
--provider <provider>auto | codex | claude(defaultauto)--model <model>model id when provider is fixed--agent <target>codex | claude | both(used with--provider auto)--notes <text>custom notes for AI fix prompt--focus <text>merged into notes--show-ai-file-ops/--no-show-ai-file-opsstream compact AI file-operation events (defaulttrue)--max-files <count>scan file cap (default20000, clamped to80..120000)--max-passes <count>AI fix hard pass cap (clamped to1..12); when omitted, starts from3and can adaptively grow up to12if actionable failures remain--ai-timeout-sec <seconds>timeout per AI subprocess (default1800, clamped to60..14400)--dry-runrun detection only, no AI edits--format <format>text | json(controls error output format)-y, --yesnon-interactive execution choices
primer-ai generate-logs [path]
Purpose:
- AI-analyze repository deltas and generate GitHub release-note markdown in
### Changes/### Fixesstyle - default base version comes from latest section in
RELEASE_LOG.md; if no section exists, latest GitHub tag (origin) is used - store logs by version sections (
## from -> to) and prepend newest section at the top without deleting older sections - omit empty sections (
### Fixesis skipped when there are no fixes) - if AI returns no changes and no fixes, show this in console and keep the file unchanged
Options:
--from <ref>explicit base tag/ref (default: auto previous reachable tag)--to <ref>target ref (defaultHEAD)--from-version <version>base version like0.1.59that must exist on GitHub tags (origin)--to-version <version>target version like0.1.79that must exist on GitHub tags (origin)--output <path>output markdown file (defaultRELEASE_LOG.md)--thanks <handle>GitHub handle appended to each entry (optional)--stdoutprint generated markdown to stdout--no-uncommittedignore staged/unstaged/untracked local changes--provider <provider>auto | codex | claude(defaultauto)--agent <target>codex | claude | both(defaultcodex)--model <model>model id when provider is fixed--ai-timeout-sec <seconds>timeout per AI subprocess (default1800, clamped to60..14400)--show-ai-file-ops/--no-show-ai-file-opsstream AI file-operation output during generation (defaultfalse)- note: when
--from-versionor--to-versionis used, uncommitted changes are ignored automatically to keep historical range generation deterministic --format <format>text | json(controls error output format)
AI Provider Resolution
- Codex-first by default
- If provider is
auto, primer-ai prefers provider by agent target and binary availability - If no compatible
codex/claudebinary is found:initcan fall back to deterministic templates for new/empty projectsrefactorandfixfail with a provider warning
Local Development
npm install
npm run lint
npm run test
npm run buildNotes:
npm run buildonly builds distributable files and does not change version- bump version explicitly with
npm run release:patch/npm run release:minor/npm run release:major - push tags with
git push --follow-tagsto trigger automated npm publish via.github/workflows/release-publish.yml - manual fallback publish is available with
npm run release:publish - source entrypoint for local iteration:
npm run dev
Related project docs:
docs/index.mddocs/runbooks/local-dev.mdREADME.dev.md
License
MIT. See LICENSE.
