Communitygithub.com

自動化代理工作框架(Autonomous Agent Harness)

將 Claude Code 轉變為具備持久記憶、排程操作、電腦使用與任務排隊功能的完整自主代理系統。取代 Hermes、AutoGPT 等獨立代理框架,完全以 Claude Code 為基礎。

自動化代理工作框架(Autonomous Agent Harness) 是什麼?

此技能提供一個設定模式,將 Claude Code 與外部排程、記憶儲存及電腦使用整合,實現長時間自動化運作。支援平台為 Claude Code(包括互動式 `/loop` 指令與非互動式 `claude -p` CLI 模式),並需搭配 MCP 伺服器來擴充記憶與工具層。核心能力包含持久記憶(透過 Claude 內建記憶系統與 MCP 記憶伺服器)、排程任務(透過 `/loop` 或外部 cron/GitHub Actions)、遠端代理觸發(透過 CI 或 webhook 呼叫 CLI)、電腦使用(需獨立設定隔離環境),以及跨工作階段的任務佇列管理。此模式能替代 Hermes、AutoGPT 等自主代理框架,但強調使用者需明確授權與範圍限制,避免未經同意的自動操作。設定的難點在於 MCP 伺服器的正確配置、排程器的選擇(互動式 vs 非互動式)、以及電腦使用環境的獨立佈署。

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

在你喜歡的 AI 中提問

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

說明文件

自動化代理工作框架(Autonomous Agent Harness) 是做什麼的?

結合 Claude Code 的工作階段工具與額外設定的排程、記憶、電腦使用整合。這是一個設定模式,而非內建且持續運行的執行環境。

同意與安全邊界

自動化作業必須由使用者明確要求並設定範圍。除非使用者已核准該能力及當前設定的目標工作區,否則請勿建立排程、派遣遠端代理、寫入持久記憶、使用電腦控制、對外發布、修改第三方資源,或處理私人通訊。

在啟用週期性或事件驅動動作之前,建議先進行乾執行計畫並使用本地佇列檔案。請將憑證、私人工作區匯出檔、個人資料集及帳號專屬自動化流程保留在可重複使用的 ECC 成品之外。

何時啟用

  • 使用者想要一個持續執行或按排程執行的代理
  • 設定需要定時觸發的自動化工作流程
  • 建立一個能跨工作階段記住上下文內容的個人 AI 助理
  • 使用者說「每天執行這個」、「定期檢查這個」、「持續監控」
  • 想要複製 Hermes、AutoGPT 或類似自主代理框架的功能
  • 需要電腦使用與排程執行結合

架構

┌──────────────────────────────────────────────────────────────┐
│                    Claude Code 執行環境                        │
│                                                              │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌─────────────┐ │
│  │  排程    │  │  遠端    │  │  記憶    │  │  電腦      │ │
│  │  任務    │  │  代理    │  │  儲存    │  │  使用      │ │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └──────┬──────┘ │
│       │              │             │                │        │
│       ▼              ▼             ▼                ▼        │
│  ┌──────────────────────────────────────────────────────┐    │
│  │              ECC 技能 + 代理層                        │    │
│  │                                                      │    │
│  │  skills/     agents/     commands/     hooks/        │    │
│  └──────────────────────────────────────────────────────┘    │
│       │              │             │                │        │
│       ▼              ▼             ▼                ▼        │
│  ┌──────────────────────────────────────────────────────┐    │
│  │              MCP 伺服器層                             │    │
│  │                                                      │    │
│  │  memory    github    exa    supabase    browser-use  │    │
│  └──────────────────────────────────────────────────────┘    │
└──────────────────────────────────────────────────────────────┘

核心元件

1. 持久記憶(Persistent Memory)

使用 Claude Code 內建的記憶系統,並以 MCP 記憶伺服器強化結構化資料的儲存。

內建記憶(~/.claude/projects/*/memory/):

  • 使用者偏好、回饋、專案背景
  • 以帶有 frontmatter 的 markdown 檔案儲存
  • 在工作階段開始時自動載入

MCP 記憶伺服器(結構化知識圖譜):

  • 實體、關係、觀察
  • 可查詢的圖譜結構
  • 跨工作階段的持久性

記憶模式:

# 短期:當前工作階段上下文
使用 TodoWrite 進行工作階段內任務追蹤

# 中期:專案記憶檔案
寫入 ~/.claude/projects/*/memory/ 實現跨工作階段回顧

# 長期:MCP 知識圖譜
使用 mcp__memory__create_entities 儲存永久結構化資料
使用 mcp__memory__create_relations 建立關係映射
使用 mcp__memory__add_observations 新增關於已知實體的事實

2. 排程操作(Crons)

使用 Claude Code 原生排程任務在互動式工作階段內執行週期性提示。這些任務限於工作階段範圍;若需在無開啟工作階段時執行,則需使用外部排程器。不需要排程 MCP 伺服器即可使用 /loop。

設定 cron:

# 在互動式 Claude Code 工作階段中
/loop 30m 審查此儲存庫中的開放 PR 並總結 CI 失敗原因。

若要從 shell 進行一次性執行,請先設定工作目錄再呼叫 CLI:

cd "/path/to/repo" && claude -p "審查開放 PR 並總結"

使用作業系統排程器或 CI 排程來重複呼叫該命令,以實現無互動工作階段的執行。請分別設定執行者的驗證與工具權限。

實用的 cron 模式:

模式排程使用案例
每日站立會議0 9 * * 1-5審查 PR、問題、部署狀態
每週回顧0 10 * * 1程式碼品質指標、測試覆蓋率
每小時監控0 * * * *生產環境健康、錯誤率檢查
每日夜間建置0 2 * * *執行完整測試套件、安全掃描
會議前準備*/30 * * * *為即將到來的會議準備上下文

3. 派遣 / 遠端代理

讓已驗證的 CI 作業或 webhook 接收器呼叫 Claude Code 在其擁有的工作區中執行。支援的進入點是程式化 CLI 模式,而非公開的 Anthropic 派遣端點。

派遣模式:

# 在 CI 工作區內執行
cd "/path/to/repo" && claude -p "主分支建置失敗。診斷失敗原因。"

# 從 webhook 觸發
# GitHub webhook -> 已驗證 CI 執行器 -> claude -p -> 可審查的結果

# 從另一個代理觸發
claude -p "分析安全掃描的輸出結果,並為發現的問題建立議題"

4. 電腦使用(Computer Use)

電腦控制需要額外設定的整合。Anthropic 的電腦使用工具與參考環境需要一個應用程式來在隔離的桌面環境中執行工具呼叫。僅加入 MCP 套件名稱不會提供該環境。

功能:

  • 瀏覽器自動化(導航、點擊、填寫表單、截圖)
  • 桌面控制(開啟應用程式、打字、滑鼠控制)
  • 超越 CLI 的檔案系統操作

在工作框架內的使用案例:

  • 網頁 UI 的自動化測試
  • 表單填寫與資料輸入
  • 基於截圖的監控
  • 多應用程式工作流程

5. 任務佇列(Task Queue)

管理一個能跨越工作階段的持久任務佇列。

實作方式:

# 透過記憶的任務持久化
將任務佇列寫入 ~/.claude/projects/*/memory/task-queue.md

# 任務格式
---
name: task-queue
type: project
description: 自主操作所需的持久任務佇列
---

## 進行中的任務
- [ ] PR #123:如果 CI 通過則審查並核准
- [ ] 監控部署:每 30 分鐘檢查 /health,持續 2 小時
- [ ] 研究:尋找 AI 工具領域的 5 個潛在客戶

## 已完成
- [x] 每日站立會議:審查了 3 個 PR、2 個議題

取代 Hermes

Hermes 元件ECC 等效元件說明
閘道器/路由器CLI + 外部排程器已驗證的執行者啟動代理工作階段
記憶系統Claude 記憶 + MCP 記憶伺服器內建持久化 + 知識圖譜
工具註冊表MCP 伺服器動態載入的工具提供者
協調器ECC 技能 + 代理技能定義指導代理行為
電腦使用獨立設定整合在隔離環境中進行瀏覽器或桌面控制
上下文管理員工作階段管理 + 記憶ECC 2.0 工作階段生命週期
任務佇列記憶中持久化的任務清單TodoWrite + 記憶檔案

設定指南

步驟 1:設定 MCP 伺服器

記憶 MCP 為選用。 MCP 參考記憶伺服器 以 @modelcontextprotocol/server-memory 發布;版本 2026.8.31 已於 2026-09-07 在公開 npm 註冊表中驗證。它是一個參考實作,而非 ECC 內建服務。

在審閱該套件並核准使用後,將以下項目合併到 ~/.claude.json 的使用者範圍 MCP 設定中,並保留現有設定。將 MEMORY_FILE_PATH 替換為您擁有的私人目錄中的絕對路徑。請參閱 Claude Code MCP 設定 以了解 CLI 註冊及 Windows 的 cmd /c npx 設定。

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/[email protected]"],
      "env": {
        "MEMORY_FILE_PATH": "/absolute/path/to/private/memory.jsonl"
      }
    }
  }
}

請勿註冊猜測或未發布的 npm 套件:npx -y 會執行將來以該名稱發布的任何內容。在加入其他伺服器之前,請驗證確切的套件、發布者與版本。排程與電腦使用不需要先前列出的三個未發布的套件名稱。

步驟 2:建立基本 Crons

若要在互動式工作階段期間進行輪詢,請輸入:

/loop 30m 審查此儲存庫中的開放 PR 並總結 CI 失敗原因。

對於必須在關閉工作階段後仍能持續的每日或每週工作,請設定外部排程器(例如作業系統 cron 作業或 GitHub Actions)來執行核心元件步驟 2 中的一次性命令。呼叫 claude -p 來請求排程並不會佈建一個持續運行的排程器。請明確選擇排程、工作區及允許的動作後再啟用。

步驟 3:初始化記憶圖譜

# 引導您的身份與上下文
claude -p "為以下項目建立記憶實體:我(使用者個人資料)、我的專案、我的主要聯絡人。新增關於當前優先事項的觀察。"

步驟 4:啟用電腦使用(選用)

請依照上方連結的電腦使用參考環境或您已審閱的特定瀏覽器整合文件。僅授予所需的權限,並在將該環境加入排程工作流程之前,先在隔離環境中驗證一個無害的動作。

範例工作流程

自主 PR 審查員

排程:工作時間內每 30 分鐘一次
1. 檢查受監控儲存庫中的新 PR
2. 針對每個新 PR:
   - 在本機拉取分支
   - 執行測試
   - 使用程式碼審查員代理審查變更
   - 透過 GitHub MCP 發布審查評論
3. 使用審查狀態更新記憶

個人研究代理

排程:每天上午 6 點
1. 檢查記憶中的已儲存搜尋查詢
2. 對每個查詢執行 Exa 搜尋
3. 總結新發現
4. 與昨天的結果比較
5. 將摘要寫入記憶
6. 標記高優先級項目供早上審閱

會議準備代理

觸發:每個日曆事件前 30 分鐘
1. 讀取日曆事件詳細資料
2. 搜尋記憶以取得與會者的上下文
3. 提取與與會者之間的最新電子郵件/Slack 討論串
4. 準備討論要點與議程建議
5. 將準備文件寫入記憶

限制

  • 原生排程提示會共用其互動式工作階段。除非明確恢復,否則外部排程器呼叫會啟動獨立的工作階段。
  • 電腦使用需要明確的權限授予。請勿假設已有存取權限。
  • CLI 自動化依然會消耗模型用量,並受所設定提供者的限制。請選擇適當的排程器間隔。
  • 記憶檔案應保持簡潔。請封存舊資料,而不是讓檔案無限制增長。
  • 務必驗證排程任務是否成功完成。請在 cron 提示中加入錯誤處理。

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

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

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

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.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

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.

相關技能