CLI Commands
Complete reference for all ContextForge CLI commands.
All commands are available via npx @contextforge/cli <command> or if installed globally via contextforge <command>.
init
bash
npx @contextforge/cli initFirst-time setup for a project. Does all of the following in one command:
- ·Detects your project stack (Next.js, React, TypeScript, Tailwind, Supabase, etc.)
- ·Fetches the registry index
- ·Installs mandatory core packs
- ·Installs detected stack packs
- ·Writes .contextforge/config.json and lock.json
- ·Creates root pointer files (AGENTS.md and/or CLAUDE.md)
- ·Asks which AI tools to configure
bash
# With custom registry
npx @contextforge/cli init --registry https://my-registry.example.com/index.json
# Configure specific tools only
npx @contextforge/cli init --tools codex,claudeadd
bash
npx @contextforge/cli add <pack-name>Installs one additional pack from the registry into your project. Updates config.json and lock.json accordingly.
bash
npx @contextforge/cli add supabase
npx @contextforge/cli add security-baseline
npx @contextforge/cli add test-driven-developmentsync
bash
npx @contextforge/cli syncRepairs and updates your ContextForge setup. Sync is the fix-all command:
- ·Re-detects your stack and installs missing detected packs
- ·Pulls latest pack files from the registry
- ·Repairs missing or corrupted .contextforge files
- ·Cleans up old structure if you upgraded ContextForge
- ·Regenerates root pointer files if missing
If
doctor reports problems, run sync to fix them.doctor
bash
npx @contextforge/cli doctorChecks whether ContextForge is correctly installed and reports any issues. Does not modify files.
txt
$ npx @contextforge/cli doctor
✓ config.json exists
✓ lock.json exists
✓ Registry reachable
✓ All installed packs present in .contextforge
✓ AGENTS.md exists and contains ContextForge block
✓ CLAUDE.md exists and contains ContextForge block
⚠ Stack pack "tailwind-v4" detected but not installed
→ Run: npx @contextforge/cli synclist
bash
npx @contextforge/cli listLists all available packs from the registry, grouped by topic.
search
bash
npx @contextforge/cli search <query>Searches pack names, titles, descriptions, and topics in the registry.
bash
npx @contextforge/cli search react
npx @contextforge/cli search nextjs
npx @contextforge/cli search security