# Context Os

> AI Project Operating System context compiler that transforms user intent into minimal, relevant context for any AI agent across the full development lifecycle.

- Skill: `kok-o/context-os` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kok-o/context-os`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kok-o/context-os/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: kok-o (https://skillmd.com/u/kok-o)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kok-o/context-os

---

# 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:

```yaml
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:

1. Read `skill.yaml` from each relevant skill directory
2. Resolve `requires` — load mandatory dependencies
3. Check `conflicts` — ensure no incompatible skills are loaded
4. Apply `optional` — suggest but don't force
5. 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 building
- `docs/ROADMAP.md` — where are we going
- `docs/PROJECT_GRAPH.md` — project structure

**Level 2 — Architecture (load when needed):**

- `docs/ARCHITECTURE.md` — system design
- `docs/DATABASE.md` — data model
- `docs/API.md` — API contracts
- `docs/decisions/` — prior decisions

**Level 3 — Development (load per task):**

- Relevant skill `.md` files
- `docs/UI.md` — for frontend tasks
- `docs/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:

1. Remove sections not relevant to the current task
2. Prioritize: current task context > architecture > vision
3. Include recent Decision Records that affect the current task
4. 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":

1. **Analyze intent** (Stage 1)
2. **Ask clarifying questions:**
   - Users and roles?
   - Tech stack preference?
   - Mobile app needed?
   - AI features?
   - Authentication type?
   - Expected load?
   - MVP or Production?
3. **Select profile** (startup/enterprise/mvp/hackathon)
4. **Resolve skills** (Stage 2)
5. **Generate all documents** using `generators/` skill
6. **Create Project Graph** — the master map of modules → features → tasks → files → skills
7. **Output agent config** using `adapters/` skill

## Skill Discovery

Skills are discovered by scanning `.agents/skills/*/skill.yaml`. Each `skill.yaml` defines:

```yaml
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.


<!-- Source: EXAMPLES.md -->

# context-os Examples — Anti-patterns vs ContextOS Standard

## Example 1: Project Lifecycle Management

### Anti-pattern: Ad-hoc Unstructured Development

```text
Coding -> Modifying DB -> Debugging -> Redesigning UI -> Changing Architecture
All in one unstructured stream of consciousness.
```

### Best practice: ContextOS Standard (Phase-Gated Development)

```text
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)
```

<!-- Source: TROUBLESHOOTING.md -->

# 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.

