選項

agentic-os

affaan-m/ECC affaan-m/ECC

在 Claude Code 上建構具備核心架構、專門代理、斜線指令、基於檔案的記憶體以及排程自動化功能的持久性多代理作業系統。

...展開全部
0
更新時間 2026-10-01

代理式作業系統

請將 Claude Code 視為一個持久的執行環境/作業系統,而非單純的聊天會話。此技能闡述了生產環境中代理式架構所採用的架構:一種將任務路由至專門代理的內核配置、持久的基於檔案的記憶體、排程自動化,以及 JSON/Markdown 資料層。

何時啟用

  • 在 Claude Code 內建構多代理工作流程
  • 設定能在會話重新啟動後仍能持續運作的 Claude Code 自動化功能
  • 為重複性任務建立「個人作業系統」或「代理式作業系統」
  • 使用者提及「代理式作業系統」、「個人作業系統」、「多代理」、「代理協調器」、「持久性代理」
  • 規劃需在不同會話間維持上下文的長期專案

架構概覽

Agentic OS 由四個層級組成。每個層級皆為專案根目錄下的目錄。

project-root/
├── CLAUDE.md          # Kernel: identity, routing rules, agent registry
├── agents/            # Specialist agent definitions (markdown prompts)
├── .claude/commands/  # Slash commands: user-facing CLI
├── scripts/           # Daemon scripts: scheduled or event-driven tasks
└── data/              # State: JSON/markdown filesystem, no external DB

各層級職責

層級 目的 持久化
核心 (CLAUDE.md) 身分識別、路由、模型政策、代理程式註冊表 由 Git 追蹤
代理程式 (agents/) 具備範圍限定工具與記憶體的專門身分 透過 Git 追蹤
指令 (.claude/commands/) 面向使用者的斜線指令 (/daily-sync, /outreach) 由 Git 追蹤
腳本 (scripts/) 由 cron 或 webhook 觸發的 Python/JS 守護程序 由 Git 追蹤的
狀態(data/) 僅追加式日誌、專案狀態、決策記錄 Git 忽略或追蹤

核心

CLAUDE.md 即是核心。它扮演營運長/協調者的角色。克勞德會在會話開始時讀取它,並利用它來分配工作。

核心結構

# CLAUDE.md - Agentic OS Kernel

## Identity
You are the COO of [project-name]. You route tasks to specialist agents.
You never write code directly. You delegate to the right agent and synthesize results.

## Agent Registry

| Agent | Role | Trigger |
|---|---|---|
| @dev | Code, architecture, debugging | User says "build", "fix", "refactor" |
| @writer | Documentation, content, emails | User says "write", "draft", "blog" |
| @researcher | Research, analysis, fact-checking | User says "research", "analyze", "compare" |
| @ops | DevOps, deployment, infrastructure | User says "deploy", "CI", "server" |

## Routing Rules
1. Parse the user request for intent keywords
2. Match to the Agent Registry trigger column
3. Load the corresponding agent file from `agents/.md`
4. Hand off execution with full context
5. Synthesize and present the result back to the user

## Model Policies
- Default model: use the repository or harness default.
- @dev tasks: prefer a higher-reasoning model for complex architecture.
- @researcher tasks: use the configured research-capable model and approved search tools.
- Cost ceiling: warn before exceeding the project's configured spend threshold.

核心原則

核心應保持精簡且具聲明式特質。路由邏輯存於純粹的 Markdown 表格中,而非程式碼中。這使得系統無需除錯即可進行檢視與編輯。

專門代理程式

每個代理程式都是位於 agents/中,每個代理皆為獨立的 Markdown 檔案。Claude 在路由任務時會載入相關的代理檔案。

代理程式定義格式

# @dev - Software Engineer

## Identity
You are a senior software engineer. You write clean, tested, production-grade code.
You prefer simple solutions. You ask clarifying questions when requirements are ambiguous.

## Memory Scope
- Read `data/projects/.md` for context
- Read `data/decisions/` for architectural decisions
- Append execution logs to `data/logs/[email protected]`

## Tool Access
- Full filesystem access within project root
- Git operations (status, diff, commit, branch)
- Test runner access
- MCP servers as configured in `.claude/mcp.json`

## Constraints
- Always write tests for new features
- Never commit directly to `main`; use feature branches
- Prefer editing existing files over creating new ones
- Keep functions under 50 lines when possible

多代理協作模式

當任務涉及多個代理時,核心會依序或並行執行它們:

User: "Build a landing page and write the launch blog post"

Kernel routing:
1. @dev - "Build a landing page with [requirements]"
2. @writer - "Write a launch blog post for [product] using the landing page copy"
3. Kernel synthesizes both outputs into a unified response

若需並行執行,請使用 Claude Code 的背景任務功能,或透過 shell 腳本以特定代理程式上下文呼叫 Claude Code。

指令與日常工作流程

斜線指令是位於 .claude/commands/中,這些檔案定義了可重複使用的流程。

命令結構

# /daily-sync

Run the morning briefing:

1. Read `data/logs/last-sync.md` for context
2. Check project status: `git status`, pending PRs, CI health
3. Review `data/inbox/` for new tasks or decisions needed
4. Generate a summary of blockers, priorities, and next actions
5. Append the briefing to `data/logs/daily/.md`

標準命令集

指令 用途
/daily-sync 晨間簡報:現況、阻礙因素、優先順序
/outreach 執行外展工作流程(電子郵件、LinkedIn 等)
/research 深入研究並追蹤引用資料
/apply-jobs 針對目標職位量身打造履歷與求職信
/analytics 從 Stripe、GitHub 或自訂來源提取指標
/interview-prep 生成學習卡片或模擬面試題
/decision 記錄決策,包含優缺點分析與最終選擇

啟用指令

將指令檔放置於 .claude/commands/.md中。Claude Code 會自動偵測這些檔案。使用者可透過 /.

持久化記憶體

記憶體採用檔案基礎架構。不使用向量資料庫、Redis 或 PostgreSQL。 data/ 中的 JSON 和 Markdown 檔案即為資料庫。

記憶體目錄結構

data/
├── daily-logs/         # Append-only daily activity logs
├── projects/           # Per-project context files
├── decisions/          # Architectural and business decisions (ADR format)
├── inbox/              # New tasks or ideas awaiting triage
├── contacts/           # People, companies, relationship notes
└── templates/          # Reusable prompts and formats

每日日誌格式

# 2026-04-22 - Daily Log

## Sessions
- 09:00 - Session 1: Refactored auth module (@dev)
- 11:30 - Session 2: Drafted investor update (@writer)

## Decisions
- Switched from JWT to session cookies (see `data/decisions/2026-04-22-auth.md`)

## Blockers
- Waiting on API key from vendor (follow up 2026-04-24)

## Next Actions
- [ ] Merge auth refactor PR
- [ ] Send investor update for review

自動反思模式

每次會話結束時,核心程式會追加一則自反記錄:

## Reflection - Session 3
- What worked: Parallel agent execution saved 20 minutes
- What didn't: @researcher hit a paywalled source, need better source ranking
- What to change: Add `source-tier` field to research notes (A/B/C credibility)

這形成了一個回饋迴路,無需修改程式碼即可隨時間推移持續改進系統。

排程自動化

Agentic OS 的任務是透過外部 cron 依照排程執行,而非使用 Claude Code 的內建 cron(該功能會在會話結束時停止運作)。

macOS:LaunchAgent






    Label
    com.agentic.daily-sync
    ProgramArguments
    
        /claude
        --cwd
        /path/to/project
        --command
        /daily-sync
    
    StartCalendarInterval
    
        Hour
        8
        Minute
        0
    
    StandardOutPath
    /tmp/agentic-daily-sync.log


Linux:systemd Timer

# ~/.config/systemd/user/agentic-daily-sync.service
[Unit]
Description=Agentic OS Daily Sync

[Service]
Type=oneshot
ExecStart=/usr/local/bin/claude --cwd /path/to/project --command /daily-sync
# ~/.config/systemd/user/agentic-daily-sync.timer
[Unit]
Description=Run daily sync every morning

[Timer] 8:00:00
Persistent=true

[Install]
WantedBy=timers.target

跨平台:pm2

# ecosystem.config.js
module.exports = {
  apps: [{
    name: 'agentic-daily-sync',
    script: 'claude',
    args: '--cwd /path/to/project --command /daily-sync',
    cron_restart: '0 8 * * *',
    autorestart: false
  }]
};

資料層

資料層即為您的檔案系統。請使用 JSON 儲存結構化資料,並使用 Markdown 格式化敘述性內容。

JSON 用於結構化狀態

// data/projects/website-v2.json
{
  "name": "Website v2",
  "status": "in-progress",
  "milestone": "beta-launch",
  "agents_involved": ["@dev", "@writer"],
  "files": {
    "spec": "docs/website-v2-spec.md",
    "design": "designs/website-v2.fig"
  },
  "metrics": {
    "commits": 47,
    "last_session": "2026-04-22T11:30:00Z"
  }
}

Markdown 適用於敘述性內容

凡是供人類閱讀的內容,例如決策、日誌、研究筆記、聯絡人記錄等,皆應使用 Markdown 格式。

模式演進

切勿重命名現有欄位。應新增欄位,並將舊欄位標記為已棄用:

{
  "name": "Website v2",
  "status": "in-progress",
  "milestone": "beta-launch",
  "_deprecated_priority": "high",
  "priority_v2": { "level": "high", "rationale": "Blocks investor demo" }
}

如此一來,即使不使用遷移腳本,歷史資料仍可讀取。

反模式

單體式單一代理

# BAD - One agent does everything
You are a full-stack developer, writer, researcher, and DevOps engineer.

拆分為專門化的代理程式。核心負責路由處理。

無狀態會話

# BAD - No memory between sessions
Starting fresh every time Claude Code opens.

始終在 data/ ,並在會話結束時寫回。

硬編碼憑證

# BAD - API keys in agent files or CLAUDE.md
Your OpenAI API key is sk-xxxxxxxx

使用環境變數或由腳本載入的 .env 由腳本載入的檔案。代理程式應參照 process.env.API_KEY.

外部資料庫以儲存簡單狀態

# BAD - PostgreSQL for a solo user's agentic OS

在您擁有多個同時使用者或 GB 級別的資料之前,請使用 JSON/Markdown 檔案。

過度設計的路由機制

# BAD - Routing logic in code instead of markdown tables
if (intent.includes('deploy')) { agent = opsAgent; }

請將路由保持為 CLAUDE.md Markdown 表格中保持路由的聲明式特性。這樣既便於檢視、編輯,也便於除錯。

最佳實務

  • CLAUDE.md 應少於 200 行,並能完整顯示於上下文視窗中
  • 每個代理程式檔案不超過 100 行,且專注於單一領域
  • data/ 敏感日誌應被 Git 忽略,決策與規格則應納入 Git 追蹤
  • 指令應採用命令式名稱: /daily-sync,而非 /run-daily-sync
  • 日誌採僅追加模式;絕不編輯過往的每日日誌
  • 每個代理程式皆設有 Memory Scope 區段來定義其讀取的檔案
  • 每次會話結束時都會寫入反思
  • 排程任務使用外部 cron(LaunchAgent、systemd、pm2),而非 Claude Code 的會話 cron
  • 成本追蹤:將每次會話的 API 消耗記錄於 data/logs/-costs.json
  • 一個專案 = 一個 Agentic OS。切勿在 CLAUDE.md 於互不相關的專案之間共用。
在 GitHub 上查看
---
name: agentic-os
description: Build persistent multi-agent operating systems on Claude Code with kernel architecture, specialist agents, slash commands, file-based memory, and scheduled automation.
---

# Agentic OS

Treat Claude Code as a persistent runtime / operating system rather than a chat session. This skill codifies the architecture used by production agentic setups: a kernel config that routes tasks to specialist agents, persistent file-based memory, scheduled automation, and a JSON/markdown data layer.

## When to Activate

- Building a multi-agent workflow inside Claude Code
- Setting up persistent Claude Code automation that survives session restarts
- Creating a "personal OS" or "agentic OS" for recurring tasks
- User says "agentic OS", "personal OS", "multi-agent", "agent coordinator", "persistent agent"
- Structuring long-running projects where context must survive across sessions

## Architecture Overview

The Agentic OS has four layers. Each layer is a directory in your project root.

```
project-root/
├── CLAUDE.md          # Kernel: identity, routing rules, agent registry
├── agents/            # Specialist agent definitions (markdown prompts)
├── .claude/commands/  # Slash commands: user-facing CLI
├── scripts/           # Daemon scripts: scheduled or event-driven tasks
└── data/              # State: JSON/markdown filesystem, no external DB
```

### Layer Responsibilities

| Layer | Purpose | Persistence |
|---|---|---|
| Kernel (`CLAUDE.md`) | Identity, routing, model policies, agent registry | Git-tracked |
| Agents (`agents/`) | Specialist identities with scoped tools and memory | Git-tracked |
| Commands (`.claude/commands/`) | User-facing slash commands (`/daily-sync`, `/outreach`) | Git-tracked |
| Scripts (`scripts/`) | Python/JS daemons triggered by cron or webhooks | Git-tracked |
| State (`data/`) | Append-only logs, project state, decision records | Git-ignored or tracked |

## The Kernel

`CLAUDE.md` is the kernel. It acts as the COO / orchestrator. Claude reads it at session start and uses it to route work.

### Kernel Structure

```markdown
# CLAUDE.md - Agentic OS Kernel

## Identity
You are the COO of [project-name]. You route tasks to specialist agents.
You never write code directly. You delegate to the right agent and synthesize results.

## Agent Registry

| Agent | Role | Trigger |
|---|---|---|
| @dev | Code, architecture, debugging | User says "build", "fix", "refactor" |
| @writer | Documentation, content, emails | User says "write", "draft", "blog" |
| @researcher | Research, analysis, fact-checking | User says "research", "analyze", "compare" |
| @ops | DevOps, deployment, infrastructure | User says "deploy", "CI", "server" |

## Routing Rules
1. Parse the user request for intent keywords
2. Match to the Agent Registry trigger column
3. Load the corresponding agent file from `agents/<name>.md`
4. Hand off execution with full context
5. Synthesize and present the result back to the user

## Model Policies
- Default model: use the repository or harness default.
- @dev tasks: prefer a higher-reasoning model for complex architecture.
- @researcher tasks: use the configured research-capable model and approved search tools.
- Cost ceiling: warn before exceeding the project's configured spend threshold.
```

### Key Principle

The kernel should be **small and declarative**. Routing logic lives in plain markdown tables, not code. This makes the system inspectable and editable without debugging.

## Specialist Agents

Each agent is a standalone markdown file in `agents/`. Claude loads the relevant agent file when routing a task.

### Agent Definition Format

```markdown
# @dev - Software Engineer

## Identity
You are a senior software engineer. You write clean, tested, production-grade code.
You prefer simple solutions. You ask clarifying questions when requirements are ambiguous.

## Memory Scope
- Read `data/projects/<current-project>.md` for context
- Read `data/decisions/` for architectural decisions
- Append execution logs to `data/logs/<date>[email protected]`

## Tool Access
- Full filesystem access within project root
- Git operations (status, diff, commit, branch)
- Test runner access
- MCP servers as configured in `.claude/mcp.json`

## Constraints
- Always write tests for new features
- Never commit directly to `main`; use feature branches
- Prefer editing existing files over creating new ones
- Keep functions under 50 lines when possible
```

### Multi-Agent Collaboration Pattern

When a task spans multiple agents, the kernel runs them sequentially or in parallel:

```
User: "Build a landing page and write the launch blog post"

Kernel routing:
1. @dev - "Build a landing page with [requirements]"
2. @writer - "Write a launch blog post for [product] using the landing page copy"
3. Kernel synthesizes both outputs into a unified response
```

For parallel execution, use Claude Code's background task capability or shell scripts that invoke Claude Code with specific agent contexts.

## Commands and Daily Workflows

Slash commands are markdown files in `.claude/commands/`. They define reusable workflows.

### Command Structure

```markdown
# /daily-sync

Run the morning briefing:

1. Read `data/logs/last-sync.md` for context
2. Check project status: `git status`, pending PRs, CI health
3. Review `data/inbox/` for new tasks or decisions needed
4. Generate a summary of blockers, priorities, and next actions
5. Append the briefing to `data/logs/daily/<date>.md`
```

### Standard Command Set

| Command | Purpose |
|---|---|
| `/daily-sync` | Morning briefing: status, blockers, priorities |
| `/outreach` | Run outreach workflow (email, LinkedIn, etc.) |
| `/research <topic>` | Deep research with citation tracking |
| `/apply-jobs` | Tailor resume + cover letter for a target role |
| `/analytics` | Pull metrics from Stripe, GitHub, or custom sources |
| `/interview-prep` | Generate flashcards or mock interview questions |
| `/decision <topic>` | Log a decision with pros/cons and chosen path |

### Activating Commands

Place command files in `.claude/commands/<command-name>.md`. Claude Code auto-discovers them. Users invoke them with `/<command-name>`.

## Persistent Memory

Memory is file-based. No vector DB, no Redis, no PostgreSQL. JSON and markdown files in `data/` are the database.

### Memory Directory Structure

```
data/
├── daily-logs/         # Append-only daily activity logs
├── projects/           # Per-project context files
├── decisions/          # Architectural and business decisions (ADR format)
├── inbox/              # New tasks or ideas awaiting triage
├── contacts/           # People, companies, relationship notes
└── templates/          # Reusable prompts and formats
```

### Daily Log Format

```markdown
# 2026-04-22 - Daily Log

## Sessions
- 09:00 - Session 1: Refactored auth module (@dev)
- 11:30 - Session 2: Drafted investor update (@writer)

## Decisions
- Switched from JWT to session cookies (see `data/decisions/2026-04-22-auth.md`)

## Blockers
- Waiting on API key from vendor (follow up 2026-04-24)

## Next Actions
- [ ] Merge auth refactor PR
- [ ] Send investor update for review
```

### Auto-Reflection Pattern

At the end of each session, the kernel appends a reflection:

```markdown
## Reflection - Session 3
- What worked: Parallel agent execution saved 20 minutes
- What didn't: @researcher hit a paywalled source, need better source ranking
- What to change: Add `source-tier` field to research notes (A/B/C credibility)
```

This creates a feedback loop that improves the system over time without code changes.

## Scheduled Automation

Agentic OS tasks run on a schedule using external cron, not Claude Code's built-in cron (which dies when the session ends).

### macOS: LaunchAgent

```xml
<!-- ~/Library/LaunchAgents/com.agentic.daily-sync.plist -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ...>
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.agentic.daily-sync</string>
    <key>ProgramArguments</key>
    <array>
        <string>/claude</string>
        <string>--cwd</string>
        <string>/path/to/project</string>
        <string>--command</string>
        <string>/daily-sync</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>8</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
    <key>StandardOutPath</key>
    <string>/tmp/agentic-daily-sync.log</string>
</dict>
</plist>
```

### Linux: systemd Timer

```ini
# ~/.config/systemd/user/agentic-daily-sync.service
[Unit]
Description=Agentic OS Daily Sync

[Service]
Type=oneshot
ExecStart=/usr/local/bin/claude --cwd /path/to/project --command /daily-sync
```

```ini
# ~/.config/systemd/user/agentic-daily-sync.timer
[Unit]
Description=Run daily sync every morning

[Timer]
OnCalendar=*-*-* 8:00:00
Persistent=true

[Install]
WantedBy=timers.target
```

### Cross-Platform: pm2

```bash
# ecosystem.config.js
module.exports = {
  apps: [{
    name: 'agentic-daily-sync',
    script: 'claude',
    args: '--cwd /path/to/project --command /daily-sync',
    cron_restart: '0 8 * * *',
    autorestart: false
  }]
};
```

## Data Layer

The data layer is your filesystem. Use JSON for structured data and markdown for narrative content.

### JSON for Structured State

```json
// data/projects/website-v2.json
{
  "name": "Website v2",
  "status": "in-progress",
  "milestone": "beta-launch",
  "agents_involved": ["@dev", "@writer"],
  "files": {
    "spec": "docs/website-v2-spec.md",
    "design": "designs/website-v2.fig"
  },
  "metrics": {
    "commits": 47,
    "last_session": "2026-04-22T11:30:00Z"
  }
}
```

### Markdown for Narrative

Use markdown for anything a human reads: decisions, logs, research notes, contact records.

### Schema Evolution

Never rename existing fields. Add new fields and mark old ones deprecated:

```json
{
  "name": "Website v2",
  "status": "in-progress",
  "milestone": "beta-launch",
  "_deprecated_priority": "high",
  "priority_v2": { "level": "high", "rationale": "Blocks investor demo" }
}
```

This keeps historical data readable without migration scripts.

## Anti-Patterns

### Monolithic Single Agent

```markdown
# BAD - One agent does everything
You are a full-stack developer, writer, researcher, and DevOps engineer.
```

Split into specialist agents. The kernel handles routing.

### Stateless Sessions

```markdown
# BAD - No memory between sessions
Starting fresh every time Claude Code opens.
```

Always read `data/` at session start and write back at session end.

### Hardcoded Credentials

```markdown
# BAD - API keys in agent files or CLAUDE.md
Your OpenAI API key is sk-xxxxxxxx
```

Use environment variables or a `.env` file loaded by scripts. Agents reference `process.env.API_KEY`.

### External Database for Simple State

```markdown
# BAD - PostgreSQL for a solo user's agentic OS
```

Use JSON/markdown files until you have multiple concurrent users or GBs of data.

### Over-Engineered Routing

```markdown
# BAD - Routing logic in code instead of markdown tables
if (intent.includes('deploy')) { agent = opsAgent; }
```

Keep routing declarative in `CLAUDE.md` markdown tables. It is inspectable, editable, and debuggable.

## Best Practices

- [ ] `CLAUDE.md` is under 200 lines and fits in context window
- [ ] Each agent file is under 100 lines and focused on one domain
- [ ] `data/` is git-ignored for sensitive logs, git-tracked for decisions and specs
- [ ] Commands use imperative names: `/daily-sync`, not `/run-daily-sync`
- [ ] Logs are append-only; never edit past daily logs
- [ ] Every agent has a `Memory Scope` section defining what files it reads
- [ ] Reflections are written at the end of every session
- [ ] Scheduled tasks use external cron (LaunchAgent, systemd, pm2), not Claude Code's session cron
- [ ] Cost tracking: log API spend per session in `data/logs/<date>-costs.json`
- [ ] One project = one Agentic OS. Do not share a single `CLAUDE.md` across unrelated projects.

所有檔案

1 個檔案

安裝 agentic-os

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/affaan-m/ECC/tree/main/skills/agentic-os # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ Claude 會自動偵測並使用該技能
儲存庫 affaan-m/ECC

相關技能

web-search
更新時間 2026-06-29
webapp-testing
更新時間 2026-06-29
lark-base
更新時間 2026-07-05
agentmail
更新時間 2026-06-29
OR