Communitygithub.com

Agentic OS

在 Claude Code 上构建持久化多智能体操作系统。涵盖内核架构、专业智能体、斜杠命令、基于文件的记忆、定时自动化和无外部数据库的状态管理。适用于在 Claude Code 上构建具有自有记忆、命令和调度的持久化多智能体系统。

Agentic OS 是什么?

Agentic OS 是一种将 Claude Code 视为持久化运行时环境的架构方法,而非一次性对话会话。它通过定义清晰的内核 (`CLAUDE.md`)、专业智能体 (`agents/`)、斜杠命令 (`.claude/commands/`)、后台脚本 (`scripts/`) 和基于文件的状态存储 (`data/`) 来构建多智能体工作流。其核心价值在于无需外部数据库(如 PostgreSQL 或 Redis)即可实现跨会话的持久化记忆、任务路由和定时自动化,特别适合需要长期运行、上下文感知的自动化项目。该架构设计强调简洁性和可维护性,内核通过声明式 Markdown 表格进行任务路由,而非复杂代码。Agentic OS 充分利用 Claude Code 的文件系统访问能力,通过 JSON/Markdown 文件实现状态管理和记忆持久化,并通过外部 cron(如 macOS 的 LaunchAgent、Linux 的 systemd 或跨平台的 pm2)实现任务调度。它还提供了丰富的内置命令集(如 `/daily-sync`、`/outreach`、`/research`)和反模式指南,帮助用户避免常见错误,确保系统稳定、可审计且易于扩展。

兼容平台✓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 是内核。它充当 COO / 协调者。Claude 在会话启动时读取它,并使用它来路由工作。

内核结构

# CLAUDE.md - Agentic OS Kernel

## 身份
你是 [项目名称] 的 COO。你将任务路由给专业智能体。
你从不直接编写代码。你委托给正确的智能体并综合结果。

## 智能体注册表

| 智能体 | 角色 | 触发条件 |
|---|---|---|
| @dev | 代码、架构、调试 | 用户说“构建”、“修复”、“重构” |
| @writer | 文档、内容、邮件 | 用户说“写”、“起草”、“博客” |
| @researcher | 研究、分析、事实核查 | 用户说“研究”、“分析”、“比较” |
| @ops | DevOps、部署、基础设施 | 用户说“部署”、“CI”、“服务器” |

## 路由规则
1. 解析用户请求中的意图关键词
2. 匹配到智能体注册表的触发条件列
3. 加载 `agents/<name>.md` 中对应的智能体文件
4. 在带有完整上下文的情况下移交执行权
5. 综合并向用户呈现结果

## 模型策略
- 默认模型:使用仓库或工具的默认设置。
- @dev 任务:对于复杂架构,优先选择高推理能力的模型。
- @researcher 任务:使用已配置的、具备研究能力的模型和经批准的搜索工具。
- 成本上限:在超过项目配置的支出阈值之前发出警告。

关键原则

内核应该小而声明式。路由逻辑存在于纯 markdown 表格中,而非代码中。这使得系统无需调试即可检查和编辑。

专业智能体

每个智能体都是 agents/ 中一个独立的 markdown 文件。Claude 在路由任务时加载相应的智能体文件。

智能体定义格式

# @dev - 软件工程师

## 身份
你是一名高级软件工程师。你编写干净、经过测试、可投产的代码。
你更喜欢简单的解决方案。当需求不明确时,你会提出澄清性问题。

## 记忆范围
- 读取 `data/projects/<current-project>.md` 获取上下文
- 读取 `data/decisions/` 获取架构决策
- 将执行日志追加到 `data/logs/<date>[email protected]`

## 工具访问权限
- 项目根目录内的完整文件系统访问权限
- Git 操作(状态、差异、提交、分支)
- 测试运行器访问权限
- 根据 `.claude/mcp.json` 配置的 MCP 服务器

## 约束
- 始终为新功能编写测试
- 永远不要直接提交到 `main`;使用功能分支
- 优先编辑现有文件而非创建新文件
- 尽可能将函数保持在 50 行以内

多智能体协作模式

当一个任务跨越多个智能体时,内核按顺序或并行运行它们:

用户:“构建一个落地页并撰写发布博客文章”

内核路由:
1. @dev - “使用 [需求] 构建一个落地页”
2. @writer - “使用落地页文案为 [产品] 撰写发布博客文章”
3. 内核将两个输出合成为一个统一的响应

对于并行执行,请使用 Claude Code 的后台任务功能或 shell 脚本,这些脚本以特定的智能体上下文调用 Claude Code。

命令与日常工作流

斜杠命令是 .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 - 每日日志

## 会话
- 09:00 - 会话 1:重构认证模块 (@dev)
- 11:30 - 会话 2:起草投资者更新 (@writer)

## 决策
- 从 JWT 切换到会话 Cookie(参见 `data/decisions/2026-04-22-auth.md`)

## 阻塞项
- 等待供应商的 API 密钥(2026-04-24 跟进)

## 下一步行动
- [ ] 合并认证重构 PR
- [ ] 发送投资者更新以供审核

自动反思模式

在每个会话结束时,内核追加一条反思:

## 反思 - 会话 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 定时器

# ~/.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": "Blocks investor demo" }
}

这使得无需迁移脚本即可读取历史数据。

反模式

单体单智能体

# 错误 - 一个智能体包揽一切
你是一名全栈开发者、作家、研究人员和 DevOps 工程师。

拆分为专业智能体。内核处理路由。

无状态会话

# 错误 - 会话之间没有记忆
每次 Claude Code 打开都从零开始。

始终在会话开始时读取 data/,并在会话结束时写回。

硬编码凭据

# 错误 - API 密钥存在于智能体文件或 CLAUDE.md 中
你的 OpenAI API 密钥是 sk-xxxxxxxx

使用环境变量或由脚本加载的 .env 文件。智能体引用 process.env.API_KEY。

为简单状态使用外部数据库

# 错误 - 为单人用户的智能体操作系统使用 PostgreSQL

er 在拥有多个并发用户或 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
  • 日志是仅追加的;永远不要编辑过去的每日日志
  • 每个智能体有一个记忆范围部分,定义它读取哪些文件
  • 在每个会话结束时编写反思
  • 定时任务使用外部 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.

相关技能