autonomous-agent-harness
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAutonomous Agent Harness
自主Agent套件
Turn Claude Code into a persistent, self-directing agent system using only native features and MCP servers.
仅使用原生功能和MCP服务器,将Claude Code转化为持久化、自导向的Agent系统。
When to Activate
激活场景
- User wants an agent that runs continuously or on a schedule
- Setting up automated workflows that trigger periodically
- Building a personal AI assistant that remembers context across sessions
- User says "run this every day", "check on this regularly", "keep monitoring"
- Wants to replicate functionality from Hermes, AutoGPT, or similar autonomous agent frameworks
- Needs computer use combined with scheduled execution
- 用户需要持续运行或按计划运行的Agent
- 搭建定期触发的自动化工作流
- 构建跨会话记住上下文的个人AI助手
- 用户提到「每天运行这个」、「定期检查这个」、「持续监控」
- 需要复现Hermes、AutoGPT或同类自主Agent框架的功能
- 需要结合定时执行的计算机操作能力
Architecture
架构
┌──────────────────────────────────────────────────────────────┐
│ Claude Code Runtime │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Crons │ │ Dispatch │ │ Memory │ │ Computer │ │
│ │ Schedule │ │ Remote │ │ Store │ │ Use │ │
│ │ Tasks │ │ Agents │ │ │ │ │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ ECC Skill + Agent Layer │ │
│ │ │ │
│ │ skills/ agents/ commands/ hooks/ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ MCP Server Layer │ │
│ │ │ │
│ │ memory github exa supabase browser-use │ │
│ └──────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘┌──────────────────────────────────────────────────────────────┐
│ Claude Code Runtime │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ Crons │ │ Dispatch │ │ Memory │ │ Computer │ │
│ │ Schedule │ │ Remote │ │ Store │ │ Use │ │
│ │ Tasks │ │ Agents │ │ │ │ │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ ECC Skill + Agent Layer │ │
│ │ │ │
│ │ skills/ agents/ commands/ hooks/ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ MCP Server Layer │ │
│ │ │ │
│ │ memory github exa supabase browser-use │ │
│ └──────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘Core Components
核心组件
1. Persistent Memory
1. 持久化内存
Use Claude Code's built-in memory system enhanced with MCP memory server for structured data.
Built-in memory ():
~/.claude/projects/*/memory/- User preferences, feedback, project context
- Stored as markdown files with frontmatter
- Automatically loaded at session start
MCP memory server (structured knowledge graph):
- Entities, relations, observations
- Queryable graph structure
- Cross-session persistence
Memory patterns:
undefined使用Claude Code内置的内存系统,配合MCP内存服务器增强结构化数据存储能力。
内置内存 ():
~/.claude/projects/*/memory/- 用户偏好、反馈、项目上下文
- 以带frontmatter的markdown文件存储
- 会话启动时自动加载
MCP内存服务器 (结构化知识图谱):
- 实体、关系、观测记录
- 可查询的图谱结构
- 跨会话持久化
内存使用模式:
undefinedShort-term: current session context
短期:当前会话上下文
Use TodoWrite for in-session task tracking
使用TodoWrite进行会话内任务跟踪
Medium-term: project memory files
中期:项目内存文件
Write to ~/.claude/projects/*/memory/ for cross-session recall
写入~/.claude/projects/*/memory/实现跨会话召回
Long-term: MCP knowledge graph
长期:MCP知识图谱
Use mcp__memory__create_entities for permanent structured data
Use mcp__memory__create_relations for relationship mapping
Use mcp__memory__add_observations for new facts about known entities
undefined使用mcp__memory__create_entities存储永久结构化数据
使用mcp__memory__create_relations进行关系映射
使用mcp__memory__add_observations存储已知实体的新信息
undefined2. Scheduled Operations (Crons)
2. 定时操作(Crons)
Use Claude Code's scheduled tasks to create recurring agent operations.
Setting up a cron:
undefined使用Claude Code的定时任务创建重复的Agent运行任务。
创建cron:
undefinedVia MCP tool
通过MCP工具
mcp__scheduled-tasks__create_scheduled_task({
name: "daily-pr-review",
schedule: "0 9 * * 1-5", # 9 AM weekdays
prompt: "Review all open PRs in affaan-m/everything-claude-code. For each: check CI status, review changes, flag issues. Post summary to memory.",
project_dir: "/path/to/repo"
})
mcp__scheduled-tasks__create_scheduled_task({
name: "daily-pr-review",
schedule: "0 9 * * 1-5", # 工作日上午9点
prompt: "Review all open PRs in affaan-m/everything-claude-code. For each: check CI status, review changes, flag issues. Post summary to memory.",
project_dir: "/path/to/repo"
})
Via claude -p (programmatic mode)
通过claude -p(编程模式)
echo "Review open PRs and summarize" | claude -p --project /path/to/repo
**Useful cron patterns:**
| Pattern | Schedule | Use Case |
|---------|----------|----------|
| Daily standup | `0 9 * * 1-5` | Review PRs, issues, deploy status |
| Weekly review | `0 10 * * 1` | Code quality metrics, test coverage |
| Hourly monitor | `0 * * * *` | Production health, error rate checks |
| Nightly build | `0 2 * * *` | Run full test suite, security scan |
| Pre-meeting | `*/30 * * * *` | Prepare context for upcoming meetings |echo "Review open PRs and summarize" | claude -p --project /path/to/repo
**常用cron模式:**
| 模式 | 定时规则 | 适用场景 |
|---------|----------|----------|
| 每日站会 | `0 9 * * 1-5` | 审查PR、Issue、部署状态 |
| 每周复盘 | `0 10 * * 1` | 代码质量指标、测试覆盖率统计 |
| 每小时监控 | `0 * * * *` | 生产环境健康度、错误率检查 |
| 夜间构建 | `0 2 * * *` | 运行全量测试套件、安全扫描 |
| 会前准备 | `*/30 * * * *` | 为即将到来的会议准备上下文 |3. Dispatch / Remote Agents
3. 调度/远程Agent
Trigger Claude Code agents remotely for event-driven workflows.
Dispatch patterns:
bash
undefined远程触发Claude Code Agent,实现事件驱动的工作流。
调度模式:
bash
undefinedTrigger from CI/CD
从CI/CD触发
curl -X POST "https://api.anthropic.com/dispatch"
-H "Authorization: Bearer $ANTHROPIC_API_KEY"
-d '{"prompt": "Build failed on main. Diagnose and fix.", "project": "/repo"}'
-H "Authorization: Bearer $ANTHROPIC_API_KEY"
-d '{"prompt": "Build failed on main. Diagnose and fix.", "project": "/repo"}'
curl -X POST "https://api.anthropic.com/dispatch"
-H "Authorization: Bearer $ANTHROPIC_API_KEY"
-d '{"prompt": "Build failed on main. Diagnose and fix.", "project": "/repo"}'
-H "Authorization: Bearer $ANTHROPIC_API_KEY"
-d '{"prompt": "Build failed on main. Diagnose and fix.", "project": "/repo"}'
Trigger from webhook
从webhook触发
GitHub webhook → dispatch → Claude agent → fix → PR
GitHub webhook → 调度 → Claude Agent → 修复 → PR
Trigger from another agent
从另一个Agent触发
claude -p "Analyze the output of the security scan and create issues for findings"
undefinedclaude -p "Analyze the output of the security scan and create issues for findings"
undefined4. Computer Use
4. 计算机操作
Leverage Claude's computer-use MCP for physical world interaction.
Capabilities:
- Browser automation (navigate, click, fill forms, screenshot)
- Desktop control (open apps, type, mouse control)
- File system operations beyond CLI
Use cases within the harness:
- Automated testing of web UIs
- Form filling and data entry
- Screenshot-based monitoring
- Multi-app workflows
利用Claude的computer-use MCP实现物理世界交互能力。
能力范围:
- 浏览器自动化(导航、点击、填写表单、截图)
- 桌面控制(打开应用、输入、鼠标控制)
- 超出CLI范围的文件系统操作
套件内适用场景:
- Web UI自动化测试
- 表单填写和数据录入
- 基于截图的监控
- 多应用工作流
5. Task Queue
5. 任务队列
Manage a persistent queue of tasks that survive session boundaries.
Implementation:
undefined管理可跨会话存续的持久化任务队列。
实现方式:
undefinedTask persistence via memory
通过内存实现任务持久化
Write task queue to ~/.claude/projects/*/memory/task-queue.md
将任务队列写入~/.claude/projects/*/memory/task-queue.md
Task format
任务格式
name: task-queue type: project description: Persistent task queue for autonomous operation
name: task-queue type: project description: Persistent task queue for autonomous operation
Active Tasks
活跃任务
- PR #123: Review and approve if CI green
- Monitor deploy: check /health every 30 min for 2 hours
- Research: Find 5 leads in AI tooling space
- PR #123: CI通过则审查并批准
- 监控部署:2小时内每30分钟检查一次/health接口
- 调研:在AI工具领域找到5个潜在线索
Completed
已完成
- Daily standup: reviewed 3 PRs, 2 issues
undefined- 每日站会:审查3个PR、2个Issue
undefinedReplacing Hermes
替代Hermes方案
| Hermes Component | ECC Equivalent | How |
|---|---|---|
| Gateway/Router | Claude Code dispatch + crons | Scheduled tasks trigger agent sessions |
| Memory System | Claude memory + MCP memory server | Built-in persistence + knowledge graph |
| Tool Registry | MCP servers | Dynamically loaded tool providers |
| Orchestration | ECC skills + agents | Skill definitions direct agent behavior |
| Computer Use | computer-use MCP | Native browser and desktop control |
| Context Manager | Session management + memory | ECC 2.0 session lifecycle |
| Task Queue | Memory-persisted task list | TodoWrite + memory files |
| Hermes组件 | ECC等效方案 | 实现方式 |
|---|---|---|
| 网关/路由 | Claude Code调度 + crons | 定时任务触发Agent会话 |
| 内存系统 | Claude内存 + MCP内存服务器 | 内置持久化 + 知识图谱 |
| 工具注册表 | MCP服务器 | 动态加载的工具提供方 |
| 编排层 | ECC技能 + Agent | 技能定义指导Agent行为 |
| 计算机操作 | computer-use MCP | 原生浏览器和桌面控制 |
| 上下文管理器 | 会话管理 + 内存 | ECC 2.0会话生命周期 |
| 任务队列 | 内存持久化任务列表 | TodoWrite + 内存文件 |
Setup Guide
搭建指南
Step 1: Configure MCP Servers
步骤1:配置MCP服务器
Ensure these are in :
~/.claude.jsonjson
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/memory-mcp-server"]
},
"scheduled-tasks": {
"command": "npx",
"args": ["-y", "@anthropic/scheduled-tasks-mcp-server"]
},
"computer-use": {
"command": "npx",
"args": ["-y", "@anthropic/computer-use-mcp-server"]
}
}
}确保中包含以下配置:
~/.claude.jsonjson
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@anthropic/memory-mcp-server"]
},
"scheduled-tasks": {
"command": "npx",
"args": ["-y", "@anthropic/scheduled-tasks-mcp-server"]
},
"computer-use": {
"command": "npx",
"args": ["-y", "@anthropic/computer-use-mcp-server"]
}
}
}Step 2: Create Base Crons
步骤2:创建基础Crons
bash
undefinedbash
undefinedDaily morning briefing
每日早间简报
claude -p "Create a scheduled task: every weekday at 9am, review my GitHub notifications, open PRs, and calendar. Write a morning briefing to memory."
claude -p "Create a scheduled task: every weekday at 9am, review my GitHub notifications, open PRs, and calendar. Write a morning briefing to memory."
Continuous learning
持续学习
claude -p "Create a scheduled task: every Sunday at 8pm, extract patterns from this week's sessions and update the learned skills."
undefinedclaude -p "Create a scheduled task: every Sunday at 8pm, extract patterns from this week's sessions and update the learned skills."
undefinedStep 3: Initialize Memory Graph
步骤3:初始化内存图谱
bash
undefinedbash
undefinedBootstrap your identity and context
初始化你的身份和上下文
claude -p "Create memory entities for: me (user profile), my projects, my key contacts. Add observations about current priorities."
undefinedclaude -p "Create memory entities for: me (user profile), my projects, my key contacts. Add observations about current priorities."
undefinedStep 4: Enable Computer Use (Optional)
步骤4:启用计算机操作(可选)
Grant computer-use MCP the necessary permissions for browser and desktop control.
为computer-use MCP授予浏览器和桌面控制所需的必要权限。
Example Workflows
示例工作流
Autonomous PR Reviewer
自主PR审查员
Cron: every 30 min during work hours
1. Check for new PRs on watched repos
2. For each new PR:
- Pull branch locally
- Run tests
- Review changes with code-reviewer agent
- Post review comments via GitHub MCP
3. Update memory with review statusCron:工作时间每30分钟运行一次
1. 检查关注仓库的新PR
2. 对每个新PR:
- 拉取分支到本地
- 运行测试
- 使用代码审查Agent审查变更
- 通过GitHub MCP发布审查评论
3. 更新内存中的审查状态Personal Research Agent
个人调研Agent
Cron: daily at 6 AM
1. Check saved search queries in memory
2. Run Exa searches for each query
3. Summarize new findings
4. Compare against yesterday's results
5. Write digest to memory
6. Flag high-priority items for morning reviewCron:每天早上6点运行
1. 检查内存中保存的搜索查询
2. 为每个查询运行Exa搜索
3. 汇总新发现
4. 和昨日结果对比
5. 将摘要写入内存
6. 标记高优先级项供早间审查Meeting Prep Agent
会议准备Agent
Trigger: 30 min before each calendar event
1. Read calendar event details
2. Search memory for context on attendees
3. Pull recent email/Slack threads with attendees
4. Prepare talking points and agenda suggestions
5. Write prep doc to memory触发时机:每个日历事件前30分钟
1. 读取日历事件详情
2. 搜索内存中与会者相关上下文
3. 拉取近期和与会者的邮件/Slack对话
4. 准备谈话要点和议程建议
5. 将准备文档写入内存Constraints
约束说明
- Cron tasks run in isolated sessions — they don't share context with interactive sessions unless through memory.
- Computer use requires explicit permission grants. Don't assume access.
- Remote dispatch may have rate limits. Design crons with appropriate intervals.
- Memory files should be kept concise. Archive old data rather than letting files grow unbounded.
- Always verify that scheduled tasks completed successfully. Add error handling to cron prompts.
- Cron任务在隔离会话中运行——除非通过内存,否则不会和交互会话共享上下文
- 计算机操作需要显式权限授予,不要默认拥有访问权限
- 远程调度可能存在速率限制,设计cron时请设置合理的间隔
- 内存文件应保持精简,归档旧数据避免文件无限制增长
- 始终验证定时任务是否成功完成,在cron提示中添加错误处理逻辑