agentic-os
affaan-m/ECC
在 Claude Code 上构建具有内核架构、专用代理、斜杠命令、基于文件的内存以及定时自动化功能的持久性多代理操作系统。
...展开全部代理式操作系统
请将 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 即内核。它充当首席运营官(COO)/协调者。克劳德在会话开始时读取它,并利用它来分配工作。
内核结构
# 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/中存储的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/.md`
标准命令集
| 命令 | 用途 |
|---|---|
/daily-sync |
晨会:进度、阻碍、优先级 |
/outreach |
执行外联工作流程(电子邮件、领英等) |
/research |
深入调研并追踪引用来源 |
/apply-jobs |
针对目标职位量身定制简历和求职信 |
/analytics |
从Stripe、GitHub或自定义数据源提取指标 |
/interview-prep |
生成学习卡片或模拟面试问题 |
/decision |
记录决策,包括利弊分析及最终选择 |
激活命令
将命令文件放置在 .claude/commands/. Claude Code 会自动检测这些文件。用户可通过 /.
持久化存储
内存基于文件。不使用向量数据库、Redis或PostgreSQL。JSON和Markdown文件位于 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(该 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。
---
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
复制





首页
