Communitygithub.com

agentic-os

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

agentic-os 是什么?

Agentic OS 是一项旨在将 Claude Code 转变为一个持久化、可复用的多智能体操作系统的技能。它通过定义清晰的四层架构(内核、专家智能体、命令、状态),帮助开发者构建能够跨会话持久化上下文、自动执行重复任务、并协调多个专业智能体协同工作的系统。核心是使用`CLAUDE.md`文件作为轻量级内核,通过声明式路由将任务分配给`agents/`目录下的专家智能体(如@dev、@writer),并通过`.claude/commands/`中的斜杠命令(如/daily-sync)提供用户友好的工作流接口。该系统利用基于文件的状态管理(`data/`目录),避免依赖外部数据库,并支持通过脚本(`scripts/`)实现定时或事件驱动的自动化。Agentic OS 适用于在 Claude Code 中构建“个人操作系统”或复杂的多智能体项目,非常适合需要长期运行、跨会话记忆和任务自动化的场景,其架构强调可检查性和可维护性。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Agentic OS

将 Claude Code 视为持久化运行时/操作系统,而非聊天会话。此技能将生产级代理设置的架构固化:将任务路由到专业代理的内核配置、持久化基于文件的记忆、计划自动化以及 JSON/Markdown 数据层。

何时激活

  • 在 Claude Code 内部构建多代理工作流
  • 设置可跨越会话重启持久化的 Claude Code 自动化
  • 为重复性任务创建“个人操作系统”或“代理操作系统”
  • 用户提及“代理操作系统”、“个人操作系统”、“多代理”、“代理协调器”、“持久化代理”
  • 构建需要上下文跨会话持久化的长期项目

架构概述

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 内核

## 身份
您是 [项目名称] 的运营官。您将任务路由给专业代理。
您从不直接编写代码。您委派给正确的代理并综合结果。

## 代理注册表

| 代理 | 角色 | 触发关键词 |
|---|---|---|
| @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 的后台任务功能或调用指定代理上下文的 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 - 每日日志

## 会话
- 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 每日同步

[Service]
Type=oneshot
ExecStart=/usr/local/bin/claude --cwd /path/to/project --command /daily-sync
# ~/.config/systemd/user/agentic-daily-sync.timer
[Unit]
Description=每天早上运行每日同步

[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/ 并在会话结束时写回。

硬编码凭据

# 错误 - 代理文件或 CLAUDE.md 中的 API 密钥
您的 OpenAI API 密钥是 sk-xxxxxxxx

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

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

# 错误 - 为单人用户的代理操作系统使用 PostgreSQL

使用 JSON/Markdown 文件,直到您有多个并发用户或 GB 级数据。

过度工程化的路由

# 错误 - 路由逻辑在代码中而非 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/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

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.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

api-connector-builder

Build a new API connector or provider by matching the target repo

相关技能