Communitygithub.com

Agentic OS

在 Claude Code 上建立持久性的多智能體作業系統。涵蓋核心架構、專精智能體、斜線指令、基於檔案的記憶體、排程自動化與無需外部資料庫的狀態管理。適合在 Claude Code 上建構具記憶、指令與排程能力的持久性多智能體系統時使用。

Agentic OS 是什麼?

Agentic OS 是一種將 Claude Code 視為持久運行時/作業系統而非交談會話的技能。它定義了一套生產級多智能體架構,包含一個核心配置 (CLAUDE.md) 用來將任務路由給專精智能體、基於檔案的持久記憶體、排程自動化,以及 JSON/Markdown 資料層。此技能適用於所有 Claude Code 支援的平台(桌面、CLI、GitHub Codespaces),透過分層設計(核心、智能體、指令、腳本、資料)實現跨工作階段的上下文保留與自動化。使用者可透過斜線指令(例如 /daily-sync)執行工作流程,並利用外部排程工具(如 cron、systemd、pm2)觸發定時任務,無需依賴外部資料庫或向量儲存。

相容平台✓Claude Code✓Codex CLI~Cursor✓Antigravity
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/agentic-os

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Agentic OS 是做什麼的?

將 Claude Code 視為持久的運作時環境/作業系統,而非一般的對話工作階段。此技能記錄了生產級多智能體系統所使用的架構:一個負責將任務路由給專精智能體的核心配置、基於檔案的持久記憶體、排程自動化,以及 JSON/Markdown 資料層。

啟用時機

  • 在 Claude Code 內建置多智能體工作流程
  • 設定能在工作階段重啟後仍持續運作的永久 Claude Code 自動化任務
  • 為重複性任務建立「個人作業系統」或「代理人作業系統」
  • 使用者提及「agentic OS」、「personal OS」、「multi-agent」、「agent coordinator」、「persistent agent」
  • 建構需要跨工作階段保存上下文的長期專案

架構總覽

Agentic OS 包含四個層級。每個層級對應專案根目錄中的一個目錄。

project-root/
├── CLAUDE.md          # 核心:身份、路由規則、智能體註冊表
├── agents/            # 專精智能體定義 (Markdown 提示詞)
├── .claude/commands/  # 斜線指令:使用者面向的 CLI
├── scripts/           # 後台腳本:排程或事件驅動的任務
└── data/              # 狀態:JSON/Markdown 檔案系統,無外部資料庫

各層級責任

層級用途持久性
核心 (CLAUDE.md)身份、路由、模型政策、智能體註冊表由 Git 追蹤
智能體 (agents/)具有限定工具與記憶的專精身份由 Git 追蹤
指令 (.claude/commands/)使用者面向的斜線指令 (/daily-sync、/outreach)由 Git 追蹤
腳本 (scripts/)由 cron 或 webhook 觸發的 Python/JS 後台程序由 Git 追蹤
狀態 (data/)僅追加的日誌、專案狀態、決策記錄由 Git 忽略或追蹤

核心

CLAUDE.md 是核心。它扮演營運長/協調者的角色。Claude 在每次工作階段啟動時讀取它,並依此路由工作。

核心結構

# CLAUDE.md - Agentic OS Kernel

## Identity
你是 [專案名稱] 的營運長。你負責將任務路由給專精智能體。
你永遠不會直接撰寫程式碼。你授權給適當的智能體,並匯總結果。

## Agent Registry

| Agent | 角色 | 觸發關鍵字 |
|---|---|---|
| @dev | 程式碼、架構、除錯 | 使用者說「建置」、「修復」、「重構」 |
| @writer | 文件、內容、電子郵件 | 使用者說「撰寫」、「草稿」、「部落格」 |
| @researcher | 研究、分析、事實查核 | 使用者說「研究」、「分析」、「比較」 |
| @ops | DevOps、部署、基礎設施 | 使用者說「部署」、「CI」、「伺服器」 |

## Routing Rules
1. 解析使用者請求中的意圖關鍵字
2. 比對 Agent Registry 的觸發關鍵字欄位
3. 從 `agents/<name>.md` 載入對應的智能體檔案
4. 將完整上下文移交執行
5. 綜合並將結果呈現給使用者

## Model Policies
- 預設模型:使用儲存庫或 harness 的預設設定。
- @dev 任務:對於複雜架構,優先使用推理能力更強的模型。
- @researcher 任務:使用已設定的具研究能力模型與核准的搜尋工具。
- 成本上限:在超出專案設定的花費閾值前發出警告。

關鍵原則

核心應 精簡且宣告式。路由邏輯應以純 Markdown 表格呈現,而非程式碼。這使得系統無需除錯即可被檢查與編輯。

專精智能體

每個智能體是 agents/ 目錄中獨立的 Markdown 檔案。Claude 在路由任務時載入對應的智慧體檔案。

智能體定義格式

# @dev - 軟體工程師

## Identity
你是一位資深軟體工程師。你撰寫乾淨、經過測試、符合生產標準的程式碼。
你偏好簡單的解決方案。當需求不明確時,你會提出釐清問題。

## Memory Scope
- 讀取 `data/projects/<current-project>.md` 以取得上下文
- 讀取 `data/decisions/` 以取得架構決策
- 將執行日誌附加到 `data/logs/<date>[email protected]`

## Tool Access
- 專案根目錄內的完整檔案系統存取權
- Git 操作 (status、diff、commit、branch)
- 測試執行器存取權
- 依 `.claude/mcp.json` 設定的 MCP 伺服器

## Constraints
- 新功能永遠必須撰寫測試
- 切勿直接提交到 `main`;應使用功能分支
- 優先編輯現有檔案而非建立新檔案
- 盡可能將函式保持在 50 行以內

多智能體協作模式

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

使用者:「建立一個登陸頁面並撰寫 launch 部落格文章」

核心路由:
1. @dev - 「使用 [需求] 建立一個登陸頁面」
2. @writer - 「使用登陸頁面文案為 [產品] 撰寫 launch 部落格文章」
3. 核心將兩個產出綜合為統一的回應

對於並行執行,可使用 Claude Code 的背景任務功能或呼叫 Claude Code 並指定特定智能體上下文的 shell 腳本。

指令與日常工作流程

斜線指令是位於 .claude/commands/ 的 Markdown 檔案。它們定義了可重複使用的工作流程。

指令結構

# /daily-sync

執行晨間簡報:

1. 讀取 `data/logs/last-sync.md` 以取得上下文
2. 檢查專案狀態:`git status`、待審 PR、CI 健康狀態
3. 檢閱 `data/inbox/` 是否有新任務或待決策事項
4. 產生障礙、優先事項與下一步行動的摘要
5. 將簡報附加到 `data/logs/daily/<date>.md`

標準指令集

指令用途
/daily-sync晨間簡報:狀態、障礙、優先事項
/outreach執行外展工作流程 (電子郵件、LinkedIn 等)
/research <topic>深度研究並追蹤引用來源
/apply-jobs為特定職位量身打造履歷與求職信
/analytics從 Stripe、GitHub 或自訂來源提取指標
/interview-prep產生學習卡或模擬面試問題
/decision <topic>記錄一項決策,包含優缺點與選擇路徑

啟用指令

將指令檔案放在 .claude/commands/<command-name>.md。Claude Code 會自動發現它們。使用者透過 /<command-name> 呼叫它們。

持久記憶體

記憶體以檔案為基礎。無需向量資料庫、Redis 或 PostgreSQL。data/ 中的 JSON 和 Markdown 檔案就是資料庫。

記憶體目錄結構

data/
├── daily-logs/         # 僅追加的每日活動日誌
├── projects/           # 各專案的上下文檔案
├── decisions/          # 架構與業務決策 (ADR 格式)
├── inbox/              # 待處理的新任務或想法
├── contacts/           # 人員、公司、關係筆記
└── templates/          # 可重複使用的提示詞與格式

每日日誌格式

# 2026-04-22 - Daily Log

## Sessions
- 09:00 - Session 1: 重構驗證模組 (@dev)
- 11:30 - Session 2: 草擬投資人更新 (@writer)

## Decisions
- 從 JWT 切換至 session cookie (參見 `data/decisions/2026-04-22-auth.md`)

## Blockers
- 等待供應商的 API 金鑰 (於 2026-04-24 跟進)

## Next Actions
- [ ] 合併驗證重構 PR
- [ ] 傳送投資人更新以尋求審閱

自動反思模式

每次工作階段結束時,核心會附加一段反思:

## Reflection - Session 3
- 有效的方法:並行執行智能體節省了 20 分鐘
- 無效的方法:@researcher 遇到了付費來源,需要更好的來源排名
- 需要改變:在研究筆記中加入 `source-tier` 欄位 (A/B/C 可信度)

這建立了一個無需修改程式碼即可隨時間改善系統的回饋循環。

排程自動化

Agentic OS 任務使用外部 cron 排程執行,而非 Claude Code 內建的 cron(後者會在工作階段結束時消失)。

macOS: LaunchAgent

<!-- ~/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

# ~/.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]
OnCalendar=*-*-* 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": "影響投資人示範" }
}

這樣可以在無需遷移腳本的情況下保持歷史資料的可讀性。

反模式

單一巨型智能體

# 錯誤 - 一個智能體做所有事
你是一位全端開發者、作家、研究員和 DevOps 工程師。

應拆分為專精智能體。核心負責路由。

無狀態工作階段

# 錯誤 - 工作階段之間沒有記憶體
每次 Claude Code 開啟都從頭開始。

應在工作階段開始時始終讀取 data/,並在工作階段結束時寫入。

硬編碼憑證

# 錯誤 - API 金鑰寫在智能體檔案或 CLAUDE.md 中
你的 OpenAI API 金鑰是 sk-xxxxxxxx

應使用環境變數或由腳本載入的 .env 檔案。智能體應參考 process.env.API_KEY。

為簡單狀態使用外部資料庫

# 錯誤 - 為單人使用的 agentic OS 使用 PostgreSQL

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

過度設計的路由

# 錯誤 - 路由邏輯寫在程式碼而非 Markdown 表格中
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/<date>-costs.json
  • 一個專案 = 一個 Agentic OS。請勿在不同專案間共用單一 CLAUDE.md。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

相關技能