Community程式設計與開發github.com

Azkae/agent-skills

此技能應在使用者要求產生新代理(或 agent-shell)時使用。它會為新代理建立一個隔離的 git worktree、執行儲存庫設定,然後啟動代理。

agent-skills 是什麼?

此技能為 AI 代理提供一個自動化流程,用於在使用者要求時產生新的代理 shell。它能在隔離的 git worktree 中建立新代理,並負責執行必要的儲存庫設定(如安裝依賴項或複製設定檔),最後在 Emacs 中啟動代理。這項功能對於需要同時處理多個隔離任務的開發者特別有用,例如同時進行功能開發與錯誤修復。該技能支援 Claude、Codex 及 Opencode 等多種代理,並會使用目前正在執行此技能的同一代理,除非使用者另行指定。其運作原理為建立 git worktree、執行儲存庫相關設定,並透過 emacsclient 在 Emacs 的 agent-shell 中啟動代理。

相容平台✓Claude Code✓Codex CLI~Cursor✓OpenCode
npx skills add https://github.com/Azkae/agent-skills/tree/HEAD/skills/agent-shell

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

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

說明文件

建立新的 agent-shell

在使用者要求時產生新的 agent-shell。新的代理透過 agent-shell 在 Emacs 內執行,並在隔離的 git worktree 中運作。

步驟

1. 確定參數

  • 提示:新代理應該處理什麼任務?如果不清楚,請詢問使用者。
  • 名稱:一個簡短、以 kebab-case 格式命名的 worktree 名稱,根據任務而定(例如 refactor-auth、fix-login-bug、add-dark-mode)。
  • 代理:要使用的代理(例如 claude、codex、opencode)。除非使用者另行指定,否則應使用目前正在執行此技能的同一代理。

2. 建立 worktree

在目前儲存庫的 .agent-shell/worktrees/ 目錄下建立一個 git worktree,分支名稱為 agent/<name>:

git worktree add -b "agent/<name>" ".agent-shell/worktrees/<name>"

3. 執行儲存庫設定

檢查 worktree 中的設定說明並執行它們。請尋找:

  • CLAUDE.md、AGENTS.md、README.md — 設定/建置/安裝指令
  • Makefile — make setup 或 make install
  • package.json — npm install / npm ci / pnpm install / yarn install
  • pyproject.toml / requirements.txt — uv sync / pip install -e .
  • Gemfile — bundle install
  • Cargo.toml — cargo fetch
  • .env.example — 複製為 .env

在 worktree 目錄內執行設定指令:

cd ".agent-shell/worktrees/<name>" && <setup-command>

4. 在 Emacs 中啟動代理

呼叫 emacsclient 啟動新的代理 shell:

emacsclient -e '(my/agent-shell-make
   :prompt "<任務描述>"
   :name "<worktree-name>"
   :agent "<agent>"
   :directory "<worktree-的絕對路徑>")'

範例:

emacsclient -e '(my/agent-shell-make
   :prompt "將驗證功能重構為使用 async/await。請參閱 @..."
   :name "refactor-auth"
   :agent "claude"
   :directory "/Users/me/projects/my-app/.agent-shell/worktrees/refactor-auth")'

對 :directory 請使用絕對路徑。

5. 回報給使用者

告訴使用者:

  • worktree 路徑與分支名稱
  • 已執行哪些設定(或無需設定)
  • 新的代理已在 Emacs 中啟動

規則

  • 始終在目前儲存庫的 .agent-shell/worktrees/ 內建立 worktree。
  • 始終為 worktree 建立名為 agent/<name> 的新分支。
  • 始終對 :directory 使用絕對路徑。
  • 除非使用者另行指定,否則使用目前正在執行此技能的同一 :agent。
  • 所有指令皆透過 Bash 工具執行。
  • 如果 Emacs 未執行或 emacsclient 失敗,請將錯誤回報給使用者,並附上可手動執行的指令。

相關技能