name: ai-context-generator description: | Generates .ai-context knowledge base for coding agents. Activate when: (1) setting up a new project for AI-assisted development, (2) user asks to "create project knowledge" or "setup ai-context", (3) existing .ai-context needs regeneration. Creates tiered documentation structure optimized for agent comprehension and token efficiency.
AI Context Generator
A reusable skill for creating project knowledge bases that help coding agents work faster and smarter.
๐ฏ When to Use This Skill
Activate when:
- Setting up a new project for AI-assisted development
- User requests: "create ai-context", "setup project knowledge", "generate .ai-context"
- Existing
.ai-contextis outdated and needs regeneration - After major project restructuring
Do NOT activate when:
- Project already has fresh
.ai-context(checkSKILL.mddate) - User asks for unrelated documentation
- Simple code tasks with clear existing context
๐ What This Skill Generates
Creates a .ai-context/ directory with:
.ai-context/
โโโ SKILL.md # Entry point with activation rules
โโโ DYNAMICS.md # Active issues & constraints (Dynamic)
โโโ references/
โ โโโ PROJECT-ESSENCE.md # What & why (High stability)
โ โโโ ARCHITECTURE.md # Component relationships (Medium stability)
โ โโโ DECISIONS.md # Design decisions (Update on change)
โโโ meta/
โโโ MAINTENANCE.md # How to maintain this knowledge
โโโ templates/ # (Optional) Custom templates
โโโ scripts/ # (Optional) Maintenance scripts
Stability Tiers
| Tier | File | Update Frequency | Token Budget |
|---|---|---|---|
| 0 | PROJECT-ESSENCE.md | Quarterly / Major version | ~500 tokens |
| 1 | ARCHITECTURE.md | Monthly / Sprint | ~1000 tokens |
| 2 | DECISIONS.md | Per decision change | ~800 tokens |
| 3 | DYNAMICS.md | As needed (issues) | ~600 tokens |
๐ง Generation Process
Step 1: Gather Project Intelligence
Before generating, collect:
โก Read AGENTS.md (if exists) โ operational rules
โก Read README.md โ user-facing description
โก Read package.json โ dependencies, scripts, entry points
โก Scan directory structure โ identify components
โก Read docs/ or litho.docs/ โ existing documentation
โก Identify key source files โ main entry points
โก Note technology stack โ frameworks, languages, platforms
Step 2: Extract Knowledge
For PROJECT-ESSENCE.md:
- What is this project? (one sentence)
- Why does it exist? (problem/solution)
- Who is it for? (target users)
- What does it provide? (key features)
- Core constraints? (security, compatibility)
For ARCHITECTURE.md:
- System diagram (ASCII or Mermaid)
- Component responsibilities
- Data flow between components
- Key dependencies
- Important patterns
For DECISIONS.md:
- Non-obvious design choices
- Trade-offs made
- Constraints accepted
- Decisions that might be revisited
For DYNAMICS.md:
- Current blockers
- Known workarounds
- Temporary constraints
- Recently resolved issues (brief)
Step 3: Generate Files
Use templates from templates/ directory:
- Start with
SKILL.mdโ entry point with activation rules - Generate
references/PROJECT-ESSENCE.mdโ core identity - Generate
references/ARCHITECTURE.mdโ component map - Generate
references/DECISIONS.mdโ design rationale - Generate
DYNAMICS.mdโ active issues - Generate
meta/MAINTENANCE.mdโ upkeep guide
Step 4: Validate Quality
โก SKILL.md has clear activation triggers
โก PROJECT-ESSENCE.md readable in 2 minutes
โก ARCHITECTURE.md shows big picture (no code)
โก DECISIONS.md justified with rationale
โก DYNAMICS.md only contains current issues
โก All files dated at top
โก Total token budget < 4000 tokens
๐ Writing Principles
Do:
- โ Write for someone who knows nothing about the project
- โ Use diagrams over paragraphs
- โ Focus on "why" not "how"
- โ Keep files under 150 lines each
- โ Link between related sections
- โ Include "Last updated" dates
Don't:
- โ Copy-paste code snippets (link to files instead)
- โ Document every file/function
- โ Include details that change frequently
- โ Duplicate content across files
- โ Use jargon without context
๐ Integration with AGENTS.md
AGENTS.md = "How to work" (commands, style, rules)
.ai-context = "What the project is" (architecture, decisions, issues)
Both should be read at session start. They serve different purposes and should not overlap.
๐ Template Reference
Templates are provided in templates/:
| Template | Purpose |
|---|---|
skill.md.tmpl |
SKILL.md with placeholder prompts |
essence.md.tmpl |
PROJECT-ESSENCE.md structure |
architecture.md.tmpl |
ARCHITECTURE.md with diagram prompts |
decisions.md.tmpl |
DECISIONS.md with ADR format |
dynamics.md.tmpl |
DYNAMICS.md with status tracking |
maintenance.md.tmpl |
MAINTENANCE.md guide |
๐ ๏ธ Automation Scripts
Scripts in scripts/ can help with:
| Script | Purpose |
|---|---|
generate.ts |
Interactive generation from templates |
check-drift.ts |
Compare documented vs actual structure |
audit-dynamics.ts |
Flag stale issues (>30 days) |
๐ก Example Usage
User: "Setup ai-context for my project"
Agent:
- Activate this skill
- Read AGENTS.md, README.md, package.json
- Scan directory structure
- Generate each file using templates
- Ask clarifying questions if needed:
- "What's the main problem this project solves?"
- "Any non-obvious design decisions I should know about?"
- "Current blockers or workarounds?"
โ ๏ธ Important Notes
- Generated knowledge is a starting point, not final truth
- Agent should verify against actual code during first session
- User should review generated content for accuracy
- Schedule regular audits (monthly recommended)
๐ References
This skill creates knowledge bases optimized for AI agents. For questions or improvements, see MAINTENANCE.md.