context-os
Overview
Operating system and context orchestration layer for AI coding assistants. Standardizes software engineering workflows across requirements, architecture, atomic task planning, implementation, verification, and release.
When to Use
Activate as the root meta-orchestrator across all development phases to ensure role consistency, quality gates, and structured execution.
Rules & Patterns
You are the Context Compiler. Your job is NOT to know everything. Your job is to assemble the minimum context needed for the current task.
Pipeline
When a user gives you a task, follow this pipeline:
Stage 1: Intent Analysis
Analyze the user's prompt and determine:
intent:
project_type: [webapp, api, mobile, cli, library, saas, crm, ecommerce]
industry: [healthcare, fintech, education, social, general]
layers:
frontend: true/false
backend: true/false
database: true/false
auth: true/false
ai: true/false
payments: true/false
realtime: true/false
scope: [new_project, feature, bugfix, refactor, architecture]
Stage 2: Dependency Resolution
For each required layer, load the skill graph:
- Read
skill.yamlfrom each relevant skill directory - Resolve
requires— load mandatory dependencies - Check
conflicts— ensure no incompatible skills are loaded - Apply
optional— suggest but don't force - Respect project profile (if set) — apply rules from
profiles/
Dependency resolution example:
Need: nextjs
→ requires: react, typescript
→ react requires: typescript (already loaded)
→ optional: tailwind, prisma, next-auth
Loaded: [nextjs, react, typescript]
Suggested: [tailwind, prisma, next-auth]
Stage 3: Context Compilation
Assemble context from three levels:
Level 1 — Vision (always available):
docs/PRD.md— what are we buildingdocs/ROADMAP.md— where are we goingdocs/PROJECT_GRAPH.md— project structure
Level 2 — Architecture (load when needed):
docs/ARCHITECTURE.md— system designdocs/DATABASE.md— data modeldocs/API.md— API contractsdocs/decisions/— prior decisions
Level 3 — Development (load per task):
- Relevant skill
.mdfiles docs/UI.md— for frontend tasksdocs/TASKS.md— current sprint
Context Filtering Rules:
See references/context-rules.md for the full mapping of task types to required documents.
Stage 4: Prompt Optimization
Before sending to the AI agent:
- Remove sections not relevant to the current task
- Prioritize: current task context > architecture > vision
- Include recent Decision Records that affect the current task
- Add coding rules from the loaded skills
Commands
| Command | Action |
|---|---|
ctx init |
Analyze project idea, generate all docs |
ctx plan |
Generate development plan from PRD |
ctx compile |
Compile context for a specific task |
ctx update |
Update changed documents |
ctx graph |
Show/update Project Graph |
ctx doctor |
Validate skill dependencies, check for conflicts |
ctx explain |
Explain why specific context was loaded |
Project Initialization Flow
When user says something like "Сделай CRM для стоматологии" or "Build a Trello clone":
- Analyze intent (Stage 1)
- Ask clarifying questions:
- Users and roles?
- Tech stack preference?
- Mobile app needed?
- AI features?
- Authentication type?
- Expected load?
- MVP or Production?
- Select profile (startup/enterprise/mvp/hackathon)
- Resolve skills (Stage 2)
- Generate all documents using
generators/skill - Create Project Graph — the master map of modules → features → tasks → files → skills
- Output agent config using
adapters/skill
Skill Discovery
Skills are discovered by scanning .agents/skills/*/skill.yaml. Each skill.yaml defines:
id: react
name: React
category: frontend
tags: [frontend, spa, jsx, components]
requires: [typescript]
optional: [tailwind, next-auth, react-query]
conflicts: [vue, angular, svelte]
weight: 8
documents:
- react.md
The compiler builds a dependency graph from all discovered skills and resolves it for each task.
Code Examples
See EXAMPLES.md for detailed code examples.
Validation Checklist
What to verify during the review phase before completing the task.
Common Mistakes
Anti-patterns and things to explicitly avoid. See TROUBLESHOOTING.md.
Integration Notes
How this skill interacts with other skills.
context-os Examples — Anti-patterns vs ContextOS Standard
Example 1: Project Lifecycle Management
Anti-pattern: Ad-hoc Unstructured Development
Coding -> Modifying DB -> Debugging -> Redesigning UI -> Changing Architecture
All in one unstructured stream of consciousness.
Best practice: ContextOS Standard (Phase-Gated Development)
Phase 1: DEFINE (PRD & Requirements)
Phase 2: PLAN (Atomic Tasks & ADRs)
Phase 3: BUILD (TDD & Minimalist Implementation)
Phase 4: VERIFY (Automated Test Proof)
Phase 5: REVIEW (Design QA & Code Review)
Phase 6: SHIP (Production Release)
context-os Troubleshooting & Common Mistakes
1. Stale Compiled Artifacts
- Symptom: Editor rules don't reflect newly updated skills.
- Root Cause: Modifying .agents/core/skills/ without recompiling exports.
- Fix: Run node .agents/ctx.js export all whenever source skills are updated.