Claude OS Documentation

repository·main·Indexed 18 days ago

https://github.com/brobertsaz/claude-os

A persistent memory and knowledge management system for Claude Code. It provides a local, secure knowledge base for remembering architectural decisions and project context across sessions. Features include a hybrid indexing system (structural and semantic), natural language memory management, cross-KB search via the /api/kb/search-all endpoint, and an MCP server. It includes tools for project initialization, session management, and integration with Agent-OS for spec-driven development.

Tokens
67.7K
Snippets
214
Records
303
Agent score
64%

What's inside Claude OS

  1. What is Claude OS?

    main

    Claude OS is an AI operating system designed for AI-assisted development. It transforms Claude from a generalist model into a project-specific expert by providing it with persistent memory, automatic learning, and deep codebase understanding.

    Key capabilities include:

    • Persistent Memory: Remembers project details across all sessions.
    • Automatic Learning: Learns from conversations, commits, and decisions.
    • Codebase Intelligence: Understands the entire codebase, including architectural decisions, patterns, and edge cases.
    • Style Adaptation: Adapts responses to match your specific coding style and conventions.
  2. Format tasks in tasks.md for Kanban synchronization

    main

    The Kanban board parses tasks.md files to extract tasks. While legacy formats are supported, the Checkbox Format is recommended for optimal integration with agent-os.

    Tasks must use checkboxes and include a numeric prefix (e.g., 1.0, 2.1) for correct parsing.

    - [x] 1.0 Complete database layer
      - [x] 1.1 Write 2-8 focused tests for database models
      - [x] 1.2 Create migration: add_manual_time_slots_support
    - [ ] 2.0 Complete service layer
      - [ ] 2.1 Write 2-8 focused tests for services

    Classic Format (Legacy Support)

    ### PHASE1-TASK1: Database Setup
    **Title:** Setup Database Schema
    **Description:** Create all required database tables
    **Estimated Time:** 2 hours
    **Risk Level:** low
    **Status:** ✅ COMPLETED
    - [x] 1.0 Complete database layer
      - [x] 1.1 Write 2-8 focused tests for database models
      - [x] 1.2 Create migration: add_manual_time_slots_support
    - [ ] 2.0 Complete service layer
      - [ ] 2.1 Write 2-8 focused tests for services
  3. Understand the Claude OS Architecture

    main

    Claude OS functions as an ecosystem that augments Claude's intelligence by providing project-specific context through several integrated layers:

    Core Components

    • Real-Time Learning System (Redis): Provides <1ms latency for immediate context updates.
    • Memory System (MCP): Provides instant access to persistent project memories.
    • Code Structure (Tree-sitter AST): A new feature that uses AST mapping to index symbols (e.g., 38,406 symbols in seconds) for deep structural understanding.
    • Semantic Knowledge Base (SQLite): The central repository containing:
      • Structural index of code symbols.
      • Semantic chunks (optimized for reduced noise).
      • Vector embeddings for semantic search.
      • Dependency graphs and PageRank scores.
      • Team patterns, conventions, and architecture documentation.

    Integration Layer

    • MCP Server (http://localhost:8051): Exposes 5 Model Context Protocol (MCP) servers per project:
      • project_memories: Persistent memories.
      • project_profile: Project standards and conventions.
      • project_index: Semantic search capabilities.
      • knowledge_docs: Project documentation.
      • code_structure: The AST-based map of the codebase.
    • Claude Code Interface: The final layer where Claude interacts with the indexed data, enabling significantly faster indexing compared to traditional methods.
  4. Understand the Session file format and entry types

    main

    Claude Code session files are stored in .jsonl (JSON Lines) format. Each line represents a single entry in the session. The following entry types are supported:

    TypeDescription
    summarySession summary (usually at start)
    userUser message
    assistantAssistant response (may contain tool_use)
    file-history-snapshotFile changes made during session
  5. Understand the Agent-OS Directory Structure

    main

    Agent-OS organizes project knowledge and feature development into a specific directory hierarchy. This structure ensures that product vision, feature specifications, and coding standards are maintained systematically:

    • agent-os/config.yml: Agent-OS configuration.
    • agent-os/product/: Contains high-level product documentation:
      • mission.md: Product mission and goals.
      • roadmap.md: Feature roadmap.
      • tech-stack.md: Technology stack definitions.
    • agent-os/specs/: Contains feature-specific directories organized by date and name (e.g., YYYY-MM-DD-feature-name/). Each spec directory includes:
      • planning/: Contains requirements.md and a visuals/ folder for assets.
      • spec.md: The detailed technical specification.
      • tasks.md: The actionable task breakdown.
    • agent-os/standards/: Contains coding standards used as agent skills.
    agent-os/
    ├── config.yml          # Agent-OS configuration
    ├── product/            # Product documentation
    │   ├── mission.md      # Product mission and goals
    │   ├── roadmap.md      # Feature roadmap
    │   └── tech-stack.md  # Technology stack
    ├── specs/              # Feature specifications
    │   └── YYYY-MM-DD-feature-name/
    │       ├── planning/
    │       │   ├── requirements.md
    │       │   └── visuals/
    │       ├── spec.md
    │       └── tasks.md
    └── standards/          # Coding standards (as skills)
  6. Implement the Context Pattern for global state

    main

    Use the Context Pattern to provide global data (like authentication) to a component tree.

    1. Create a context using createContext.
    2. Wrap the application (or a subtree) in a Provider component that manages the state.
    3. Export a custom hook (e.g., useAuth) that calls useContext and throws an error if used outside the provider. This ensures type safety and prevents runtime errors when accessing undefined contexts.
    // src/context/AuthContext.tsx
    import { createContext, useContext, useState, ReactNode } from 'react';
    
    interface AuthContextType {
      user: User | null;
      login: (credentials: Credentials) => Promise<void>;
      logout: () => void;
      isAuthenticated: boolean;
    }
    
    const AuthContext = createContext<AuthContextType | undefined>(undefined);
    
    export function AuthProvider({ children }: { children: ReactNode }) {
      const [user, setUser] = useState<User | null>(null);
    
      const login = async (credentials: Credentials) => {
        const user = await authApi.login(credentials);
        setUser(user);
      };
    
      const logout = () => {
        setUser(null);
        authApi.logout();
      };
    
      return (
        <AuthContext.Provider value={{
          user,
          login,
          logout,
          isAuthenticated: !!user
        }}>
          {children}
        </AuthContext.Provider>
      );
    }
    
    export function useAuth() {
      const context = useContext(AuthContext);
      if (!context) {
        throw new Error('useAuth must be used within AuthProvider');
      }
      return context;
    }
  7. Agent-OS Directory Structure

    main

    Agent-OS organizes project intelligence into a specific directory hierarchy. When using Agent-OS, your project should follow this structure:

    • agent-os/config.yml: Agent-OS configuration.
    • agent-os/product/: High-level product documentation including mission.md, roadmap.md, and tech-stack.md.
    • agent-os/specs/: Feature-specific specifications. Each feature resides in agent-os/specs/YYYY-MM-DD-feature-name/ and contains planning/, spec.md, and tasks.md.
    • agent-os/standards/: Coding standards categorized by backend/, frontend/, global/, and testing/.
    agent-os/
    ├── config.yml          # Agent-OS configuration
    ├── product/            # Product documentation
    │   ├── mission.md      # Product mission and goals
    │   ├── roadmap.md      # Feature roadmap
    │   └── tech-stack.md   # Technology stack documentation
    ├── specs/              # Feature specifications
    │   └── YYYY-MM-DD-feature-name/
    │       ├── planning/
    │       ├── spec.md
    │       └── tasks.md
    └── standards/          # Coding standards
        ├── backend/
        ├── frontend/
        ├── global/
        └── testing/
  8. Use root-cause-tracing for deep errors

    main

    The root-cause-tracing skill is used when errors occur deep in the call stack or when fixing the obvious symptom does not resolve the issue. It instructs Claude to trace backward to find the original trigger instead of just fixing the point where the error appears.

    Use when:

    • Stack traces show long call chains.
    • The origin of invalid data is unclear.
    • Fixing the immediate error location fails to solve the problem.
    /claude-os-skills install root-cause-tracing
  9. Understand the Claude OS service architecture and ports

    main

    Claude OS consists of two distinct services running on different ports. It is critical to use the correct port depending on whether you are interacting with the system via a web browser or via Claude Code (MCP protocol).

    1. MCP Server (Port 8051)

    • Purpose: API server for Claude Code integration. It handles AI memory, knowledge bases, and serves API endpoints.
    • Technology: FastAPI (Python).
    • Access: Used by Claude Code via the MCP protocol.
    • ⚠️ Warning: Do NOT open http://localhost:8051 in a web browser. Browser GET requests will return a {"detail": "Method Not Allowed"} error because the server expects MCP protocol POST requests.

    2. Web UI (Port 5173)

    • Purpose: Visual interface for human users to browse knowledge bases, upload documents, search, and manage projects.
    • Technology: React + Vite.
    • Access: Open http://localhost:5173 in your web browser.

    Summary Table

    ServicePortOpen in Browser?Purpose
    MCP Server8051❌ NOFor Claude Code (API)
    Web UI5173✅ YESFor humans (visual interface)
  10. Enable Agent-OS for spec-driven development

    main

    Agent-OS is an advanced feature for complex projects that provides 8 specialized agents to manage structured feature development. It follows a workflow of gathering requirements, creating specifications, generating task breakdowns, and implementing/verifying features.

    To enable Agent-OS during initialization:

    1. Set ENABLE_AGENT_OS=true.
    2. The setup will create an agent-os/ directory structure.
    3. It will symlink specialized agents to .claude/agents/agent-os/.
    4. It will update your CLAUDE.md with an agent-os section.

    Requirements: Requires Ollama (local) or an OpenAI API key for advanced features.

  11. How Claude OS works: Core components

    main

    Claude OS achieves project-specific intelligence through several integrated systems:

    1. Real-Time Learning System: An 'always-on brain' that learns from your interactions.
    2. Memory MCP: Provides the AI with institutional memory.
    3. Semantic Knowledge Base: Turns your codebase into living documentation.
    4. Analyze-Project Skill: Uses hybrid indexing (including tree-sitter AST parsing) for lightning-fast codebase analysis.
    5. Session Management: Ensures context is preserved across different work sessions.
    6. Code Structure MCP: Maps the 'DNA' or structural layout of your codebase.
    7. MCP Integration: Acts as a bridge to Claude Code via the Model Context Protocol (MCP).