@zhanglichen/create-ai-context
v1.0.3
Published
Bootstrap .ai context layer for AI coding tools (Codex/Cursor/Claude/Aider).
Downloads
53
Maintainers
Readme
create-ai-context
A CLI tool to bootstrap an AI Context Layer (.ai/) for codebases.
It creates human-maintained rules and generates machine indexes so AI coding tools
(Codex / Cursor / Claude Code / Aider) can understand your project faster and follow your team conventions.
Quick Start (Recommended)
Run at your project root (must contain package.json):
npx @zhanglichen/create-ai-context --yesThis will:
- Create
.ai/(lowercase human-maintained spec files) - Add
scripts/ai/generate-ai-context.mjs - Add
ai:contextscript topackage.json - (Optional) append
.gitignorerules for generated artifacts - (Optional) run
npm run ai:context
Installation (Optional)
Global install
npm i -g @zhanglichen/create-ai-contextThen run:
create-ai-context --yesNote: This package is published as
@zhanglichen/create-ai-context.
Usage
Initialize (default)
npx @zhanglichen/create-ai-context init --yesOptions:
-y, --yes- non-interactive, accept defaults--skip-run- do not runai:contextafter init--skip-gitignore- do not append.gitignorerules
Examples:
npx @zhanglichen/create-ai-context init --yes --skip-runScan / Generate indexes
Run whenever the codebase structure changes (new components/hooks/services, moved folders, etc.):
npx @zhanglichen/create-ai-context scanOr:
npm run ai:contextDoctor (diagnostics)
Useful when setup or generation fails:
npx @zhanglichen/create-ai-context doctorUpdate (placeholder)
npx @zhanglichen/create-ai-context updateOutput
Human-maintained (lowercase, commit to git)
These files define your team rules and should be reviewed/maintained:
.ai/agent.md.ai/stack.md.ai/architecture.md.ai/conventions.md.ai/codebase.md.ai/task_workflow.md.ai/readme.md
Generated (uppercase, do not edit manually)
Generated by npm run ai:context:
.ai/AI_CONTEXT.json.ai/COMPONENT_MAP.md.ai/COMPONENT_TREE.json.ai/HOOK_MAP.json.ai/API_MAP.json.ai/ROUTE_MAP.json.ai/DEP_GRAPH.json.ai/COMPONENT_RELATION_GRAPH.json.ai/HOOK_DEP_GRAPH.json.ai/API_SCHEMA_MAP.json
Generated files may be ignored in git (recommended). See
.gitignoresection below.
Recommended .gitignore
Commit the lowercase files, ignore generated uppercase artifacts:
# AI Context Layer (generated)
.ai/AI_CONTEXT.json
.ai/COMPONENT_*.*
.ai/HOOK_*.json
.ai/API_*.json
.ai/ROUTE_*.json
.ai/DEP_*.json
.ai/*_GRAPH.json
.ai/*_MAP.json
.ai/*_TREE.jsonPrompt Template (Works Great in Codex/Cursor)
Copy this into your AI tool:
Follow `.ai/agent.md`.
Before coding, read: `.ai/stack.md`, `.ai/architecture.md`, `.ai/COMPONENT_MAP.md`, `.ai/AI_CONTEXT.json`.Notes
- Run this tool from the project root where
package.jsonexists. - If
.ai/already exists, the tool will not overwrite existing files. - After large refactors, run
npm run ai:contextto keep indexes up to date.
