description: Interactive wizard to add project patterns using Project Intelligence standard tags: [context, onboarding, project-intelligence, wizard] dependencies:
Project Intelligence onboarding wizard for teaching agents YOUR coding patterns Project-specific context creation w/ MVI compliance Interactive 6-question wizard โ structured context files w/ 100% pattern preservation
Context Creation Wizard applying Project Intelligence + MVI + frontmatter standards
6-question wizard โ technical-domain.md w/ tech stack, API/component patterns, naming, standards, security
MUST create technical-domain.md in project-intelligence/ dir (NOT single project-context.md)
ALL files MUST start w/ HTML frontmatter: <!-- Context: {category}/{function} | Priority: {level} | Version: X.Y | Updated: YYYY-MM-DD -->
Files MUST be <200 lines, scannable <30s. MVI formula: 1-3 sentence concept, 3-5 key points, 5-10 line example, ref link
ALL files MUST include "๐ Codebase References" section linking contextโactual code implementation
MUST update navigation.md when creating/modifying files (add to Quick Routes or Deep Dives table)
MUST assign priority based on usage: critical (80%) | high (15%) | medium (4%) | low (1%)
MUST track versions: New fileโ1.0 | Content updateโMINOR (1.1, 1.2) | Structure changeโMAJOR (2.0, 3.0)
- @project_intelligence (technical-domain.md in project-intelligence/ dir)
- @mvi_compliance (<200 lines, <30s scannable)
- @frontmatter_required (HTML frontmatter w/ metadata)
- @codebase_refs (link contextโcode)
- @navigation_update (update navigation.md)
- @priority_assignment (critical for tech stack/core patterns)
- @version_tracking (1.0 for new, incremented for updates)
- Detect existing contextโReview/Add/Replace
- 6-question interactive wizard
- Generate/update technical-domain.md
- Validation w/ MVI checklist
- Clear formatting w/ โ dividers
- Helpful examples
- Next steps guidance
Tier 1 always overrides Tier 2/3 - standards are non-negotiable
Help users add project patterns using Project Intelligence standard. Easiest way to teach agents YOUR coding patterns.
Value: Answer 6 questions (~5 min) โ properly structured context files โ agents generate code matching YOUR project.
Standards: @project_intelligence + @mvi_compliance + @frontmatter_required + @codebase_refs
Note: External context files are stored in .tmp/ directory (e.g., .tmp/external-context.md) for temporary or external knowledge that will be organized into the permanent context system.
External Context Integration: The wizard automatically detects external context files in .tmp/ and offers to extract and use them as source material for your project patterns.
/add-context # Interactive wizard (recommended, saves to project)
/add-context --update # Update existing context
/add-context --tech-stack # Add/update tech stack only
/add-context --patterns # Add/update code patterns only
/add-context --global # Save to global config (~/.config/opencode/) instead of project
Run: /add-context
What happens:
.opencode/context/project-intelligence/ in your project (always local).tmp/ (if found, offers to extract)6 Questions (~5 min):
Done! Agents now use YOUR patterns.
Management Options:
/add-context --update/context harvest (extract, organize, clean)/context harvest/context harvest (cleans up .tmp/ files)Determine where project intelligence files should be saved. This runs BEFORE anything else.
Default behavior: Always use local .opencode/context/project-intelligence/.
Override: --global flag saves to ~/.config/opencode/context/project-intelligence/ instead.
Resolution:
--global flag โ $CONTEXT_DIR = ~/.config/opencode/context/project-intelligence/$CONTEXT_DIR = .opencode/context/project-intelligence/ (always local)If .opencode/context/ doesn't exist yet, create it silently โ no prompt needed. The directory structure is part of the output shown in Stage 4.
Variable: $CONTEXT_DIR is set here and used in all subsequent stages.
Check: .tmp/ directory for external context files (e.g., .tmp/external-context.md, .tmp/context-*.md)
If external files found:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Found external context files in .tmp/
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Files found:
๐ .tmp/external-context.md (2.4 KB)
๐ .tmp/api-patterns.md (1.8 KB)
๐ .tmp/component-guide.md (3.1 KB)
These files can be extracted and organized into permanent context.
Options:
1. Continue with /add-context (ignore external files for now)
2. Manage external files first (via /context harvest)
Choose [1/2]: _
If option 1 (Continue):
If option 2 (Manage external files):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Manage External Context Files
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
To manage external context files, use the /context command:
/context harvest
This will:
โ Extract knowledge from .tmp/ files
โ Organize into project-intelligence/
โ Clean up temporary files
โ Update navigation.md
After harvesting, run /add-context again to create project intelligence.
Ready to harvest? [y/n]: _
If yes: Exit and run /context harvest
If no: Continue with /add-context (Stage 1)
Check: $CONTEXT_DIR (set in Stage 0.5 โ either .opencode/context/project-intelligence/ or ~/.config/opencode/context/project-intelligence/)
If exists:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Found existing project intelligence!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Files found:
โ technical-domain.md (Version: 1.2, Updated: 2026-01-15)
โ business-domain.md (Version: 1.0, Updated: 2026-01-10)
โ navigation.md
Current patterns:
๐ฆ Tech Stack: Next.js 14 + TypeScript + PostgreSQL + Tailwind
๐ง API: Zod validation, error handling
๐จ Component: Functional components, TypeScript props
๐ Naming: kebab-case files, PascalCase components
โ
Standards: TypeScript strict, Drizzle ORM
๐ Security: Input validation, parameterized queries
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Options:
1. Review and update patterns (show each one)
2. Add new patterns (keep all existing)
3. Replace all patterns (start fresh)
4. Cancel
Choose [1/2/3/4]: _
If user chooses 3 (Replace all):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Replace All: Preview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Will BACKUP existing files to:
.tmp/backup/project-intelligence-{timestamp}/
โ technical-domain.md (Version: 1.2)
โ business-domain.md (Version: 1.0)
โ navigation.md
Will DELETE and RECREATE:
$CONTEXT_DIR/technical-domain.md (new Version: 1.0)
$CONTEXT_DIR/navigation.md (new Version: 1.0)
Existing files backed up โ you can restore from .tmp/backup/ if needed.
Proceed? [y/n]: _
If not exists:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
No project intelligence found. Let's create it!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Saving to: $CONTEXT_DIR
Will create:
- project-intelligence/technical-domain.md (tech stack & patterns)
- project-intelligence/navigation.md (quick overview)
Takes ~5 min. Follows @mvi_compliance (<200 lines).
Ready? [y/n]: _
Only runs if user chose "Review and update" in Stage 1.
For each pattern, show currentโask Keep/Update/Remove:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Pattern 1/6: Tech Stack
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Current:
Framework: Next.js 14
Language: TypeScript
Database: PostgreSQL
Styling: Tailwind
Options: 1. Keep | 2. Update | 3. Remove
Choose [1/2/3]: _
If '2': New tech stack: _
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Pattern 2/6: API Pattern
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Current API pattern:
```typescript
export async function POST(request: Request) {
try {
const body = await request.json()
const validated = schema.parse(body)
return Response.json({ success: true })
} catch (error) {
return Response.json({ error: error.message }, { status: 400 })
}
}
Options: 1. Keep | 2. Update | 3. Remove Choose [1/2/3]: _
If '2': Paste new API pattern: _
#### Pattern 3-6: Component, Naming, Standards, Security
*(Same format: show currentโKeep/Update/Remove)*
**After reviewing all**:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Review Summary โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Changes: โ Tech Stack: Updated (Next.js 14 โ Next.js 15) โ API: Kept โ Component: Updated (new pattern) โ Naming: Kept โ Standards: Updated (+2 new) โ Security: Kept
Version: 1.2 โ 1.3 (content update per @version_tracking) Updated: 2026-01-29
Proceed? [y/n]: _
---
### Stage 2: Interactive Wizard (for new patterns)
#### Q1: Tech Stack
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Q 1/6: What's your tech stack? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples:
Your tech stack: _
**Capture**: Framework, Language, Database, Styling
#### Q2: API Pattern
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Q 2/6: API endpoint example? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Paste API endpoint from YOUR project (matches your API style).
Example (Next.js):
export async function POST(request: Request) {
const body = await request.json()
const validated = schema.parse(body)
return Response.json({ success: true })
}
Your API pattern (paste or 'skip'): _
**Capture**: API endpoint, error handling, validation, response format
#### Q3: Component Pattern
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Q 3/6: Component example? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Paste component from YOUR project.
Example (React):
interface UserCardProps { name: string; email: string }
export function UserCard({ name, email }: UserCardProps) {
return <div className="rounded-lg border p-4">
<h3>{name}</h3><p>{email}</p>
</div>
}
Your component (paste or 'skip'): _
**Capture**: Component structure, props pattern, styling, TypeScript
#### Q4: Naming Conventions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Q 4/6: Naming conventions? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples: Files: kebab-case (user-profile.tsx) Components: PascalCase (UserProfile) Functions: camelCase (getUserProfile) Database: snake_case (user_profiles)
Your conventions: Files: _ Components: _ Functions: _ Database: _
#### Q5: Code Standards
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Q 5/6: Code standards? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples:
Your standards (one/line, 'done' when finished):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Q 6/6: Security requirements?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples:
- Validate all user input
- Use parameterized queries
- Sanitize before rendering
- HTTPS only
Your requirements (one/line, 'done' when finished):
1. _
Preview:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Preview: technical-domain.md
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
<!-- Context: project-intelligence/technical | Priority: critical | Version: 1.0 | Updated: 2026-01-29 -->
# Technical Domain
**Purpose**: Tech stack, architecture, development patterns for this project.
**Last Updated**: 2026-01-29
## Quick Reference
**Update Triggers**: Tech stack changes | New patterns | Architecture decisions
**Audience**: Developers, AI agents
## Primary Stack
| Layer | Technology | Version | Rationale |
|-------|-----------|---------|-----------|
| Framework | {framework} | {version} | {why} |
| Language | {language} | {version} | {why} |
| Database | {database} | {version} | {why} |
| Styling | {styling} | {version} | {why} |
## Code Patterns
### API Endpoint
```{language}
{user_api_pattern}
{user_component_pattern}
| Type | Convention | Example |
|---|---|---|
| Files | {file_naming} | {example} |
| Components | {component_naming} | {example} |
| Functions | {function_naming} | {example} |
| Database | {db_naming} | {example} |
{user_code_standards}
{user_security_requirements}
Implementation: {detected_files} - {desc}
Config: package.json, tsconfig.json
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Size: {line_count} lines (limit: 200 per @mvi_compliance) Status: โ MVI compliant
Save to: $CONTEXT_DIR/technical-domain.md
Looks good? [y/n/edit]: _
**Actions**:
- Confirm: Write file per @project_intelligence
- Edit: Open in editorโvalidate after
- Update: Show diffโhighlight newโconfirm
---
### Stage 4: Validation & Creation
**Validation**:
Running validation...
โ <200 lines (@mvi_compliance) โ Has HTML frontmatter (@frontmatter_required) โ Has metadata (Purpose, Last Updated) โ Has codebase refs (@codebase_refs) โ Priority assigned: critical (@priority_assignment) โ Version set: 1.0 (@version_tracking) โ MVI compliant (<30s scannable) โ No duplication
**navigation.md preview** (also created/updated):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Preview: navigation.md โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| File | Description | Priority |
|---|---|---|
| technical-domain.md | Tech stack & patterns | critical |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
**Full creation plan**:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Files to write: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CREATE $CONTEXT_DIR/technical-domain.md ({line_count} lines) CREATE $CONTEXT_DIR/navigation.md ({nav_line_count} lines)
Total: 2 files
Proceed? [y/n]: _
---
### Stage 5: Confirmation & Next Steps
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ Project Intelligence created successfully! โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Files created: $CONTEXT_DIR/technical-domain.md $CONTEXT_DIR/navigation.md
Location: $CONTEXT_DIR Agents now use YOUR patterns automatically!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ What's next? โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Test it: opencode --agent OpenCoder
"Create API endpoint" (Uses YOUR pattern!)
Review: cat $CONTEXT_DIR/technical-domain.md
Add business context: /add-context --business
Build: opencode --agent OpenCoder > "Create user auth system"
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ก Tip: Update context as project evolves โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
When you: Add library โ /add-context --update Change patterns โ /add-context --update Migrate tech โ /add-context --update
Agents stay synced!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ก Tip: Global patterns โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Want the same patterns across ALL your projects? /add-context --global โ Saves to ~/.config/opencode/context/project-intelligence/ โ Acts as fallback for projects without local context
Already have global patterns? Bring them into this project: /context migrate
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ ๐ Learn More โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Process:
ls .tmp/external-context.md .tmp/context-*.md .tmp/*-context.md 2>/dev/null/context harvest/context harvest command/context harvest to process external files/add-context again after harvest completesProcess:
ls $CONTEXT_DIR/ (path determined in Stage 0.5)cat technical-domain.md (if exists)Per pattern:
changes_to_make[]After all reviewed:
operation: create | update
template: technical-domain # Project Intelligence template
target_directory: project-intelligence
# For create/update operations
user_responses:
tech_stack: {framework, language, database, styling}
api_pattern: string | null
component_pattern: string | null
naming_conventions: {files, components, functions, database}
code_standards: string[]
security_requirements: string[]
frontmatter:
context: project-intelligence/technical
priority: critical # @priority_assignment (80% use cases)
version: {calculated} # @version_tracking
updated: {current_date}
validation:
max_lines: 200 # @mvi_compliance
has_frontmatter: true # @frontmatter_required
has_codebase_references: true # @codebase_refs
navigation_updated: true # @navigation_update
Note: External context file management (harvest, extract, organize) is handled by /context harvest command, not /add-context.
Based on tech stack, infer common structure:
Next.js: src/app/ components/ lib/ db/
React: src/components/ hooks/ utils/ api/
Express: src/routes/ controllers/ models/ middleware/
User Experience:
File Quality:
System Integration:
/add-context
# Q1: Next.js + TypeScript + PostgreSQL + Tailwind
# Q2: [pastes Next.js API route]
# Q3: [pastes React component]
# Q4-6: [answers]
โ
Created: technical-domain.md, navigation.md
/add-context
# Found existing โ Choose "1. Review and update"
# Pattern 1: Tech Stack โ Update (Next.js 14 โ 15)
# Pattern 2-6: Keep
โ
Updated: Version 1.2 โ 1.3
/add-context --tech-stack
# Current: Next.js 15 + TypeScript + PostgreSQL + Tailwind
# New: Next.js 15 + TypeScript + PostgreSQL + Drizzle + Tailwind
โ
Version 1.4 โ 1.5
/add-context
# Found external context files in .tmp/
# ๐ .tmp/external-context.md (2.4 KB)
# ๐ .tmp/api-patterns.md (1.8 KB)
#
# Options:
# 1. Continue with /add-context (ignore external files for now)
# 2. Manage external files first (via /context harvest)
#
# Choose [1/2]: 2
#
# To manage external context files, use:
# /context harvest
#
# This will:
# โ Extract knowledge from .tmp/ files
# โ Organize into project-intelligence/
# โ Clean up temporary files
# โ Update navigation.md
#
# After harvesting, run /add-context again.
# After running: /context harvest
/add-context
# No external context files found in .tmp/
# Proceeding to detect existing project intelligence...
#
# โ
Created: technical-domain.md (merged with harvested patterns)
Invalid Input:
โ ๏ธ Invalid input
Expected: Tech stack description
Got: [empty]
Example: Next.js + TypeScript + PostgreSQL + Tailwind
File Too Large:
โ ๏ธ Exceeds 200 lines (@mvi_compliance)
Current: 245 | Limit: 200
Simplify patterns or split into multiple files.
Invalid Syntax:
โ ๏ธ Invalid code syntax in API pattern
Error: Unexpected token line 3
Check code & retry.
Keep Simple: Focus on most common patterns, add more later
Use Real Examples: Paste actual code from YOUR project
Update Regularly: Run /add-context --update when patterns change
Test After: Build something simple to verify agents use patterns correctly
Q: Agents not using patterns?
A: Check file exists, <200 lines. Run /context validate
Q: See what's in context?
A: cat .opencode/context/project-intelligence/technical-domain.md (local) or cat ~/.config/opencode/context/project-intelligence/technical-domain.md (global)
Q: Multiple context files? A: Yes! Create in your project-intelligence directory. Agents load all.
Q: Remove pattern?
A: Edit directly: nano .opencode/context/project-intelligence/technical-domain.md
Q: Share w/ team?
A: Yes! Use local install (.opencode/context/project-intelligence/) and commit to repo. Team members get your patterns automatically.
Q: Local vs global?
A: Local (.opencode/) = project-specific, committed to git, team-shared. Global (~/.config/opencode/) = personal defaults across all projects. Local overrides global.
Q: Installed globally but want project patterns?
A: Run /add-context (defaults to local). Creates .opencode/context/project-intelligence/ in your project even if OAC was installed globally.
Q: Have external context files in .tmp/?
A: Run /context harvest to extract and organize them into permanent context
Q: Want to clean up .tmp/ files?
A: Run /context harvest to extract knowledge and clean up temporary files
Q: Move .tmp/ files to permanent context?
A: Run /context harvest to extract and organize them
Q: Update external context files?
A: Edit directly: nano .tmp/external-context.md then run /context harvest
Q: Remove specific external file?
A: Delete directly: rm .tmp/external-context.md then run /context harvest
/context - Manage context files (harvest, organize, validate)/context validate - Check integrity/context map - View structure