一键导入
extend-agent
Create new skills, commands, hooks, or subagents. Use when adding capabilities to Claude Code or Cursor.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create new skills, commands, hooks, or subagents. Use when adding capabilities to Claude Code or Cursor.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Promotes recurring feedback into the right skill, then guides /compact at phase boundaries.
Testing guidance for pytest, Jest/Vitest, Go, and TDD. Use when writing tests or improving coverage.
Methodical debugging with evidence and hypothesis testing. Use when troubleshooting fails or root cause is unclear.
PostgreSQL patterns for queries, schema, indexing, security. Use when writing SQL, designing schema, or adding indexes.
Reviews a GitHub PR diff for correctness, security, tests, architecture. Use when asked to review a PR or pull request.
Orchestrates the Ralph pipeline (spec-interview → PRD → execute). Use for features needing autonomous implementation.
| name | extend-agent |
| description | Create new skills, commands, hooks, or subagents. Use when adding capabilities to Claude Code or Cursor. |
<freshness_check>
MANDATORY first step on every invocation. Claude Code's extension knobs (skill frontmatter fields, subagent options, hook events, the model lineup, slash-command behavior) change frequently. The tables in this SKILL.md are a SNAPSHOT — they go stale. Verify the LIVE docs FIRST, then design.
Use WebFetch (preferred over delegating to web-research subagent, because WebFetch is often restricted in subagent contexts — the parent loop usually has it). Always go to the live URL first; if the doc has moved (HTTP 301), follow the redirect to the new canonical host.
Verified canonical hosts (as of late 2026):
https://code.claude.com/docs/en/skills — Skill frontmatter, invocation control, subagent execution, dynamic context injectionhttps://code.claude.com/docs/en/sub-agents — Subagent frontmatter, model defaults, invocationhttps://code.claude.com/docs/en/hooks — Hook events (30+), handler types, blocking output JSONhttps://code.claude.com/docs/en/slash-commands — Custom commands (note: commands are now merged into skills)https://code.claude.com/docs/en/agent-teams and /agent-view — Cross-session orchestrationhttps://code.claude.com/docs/en/context-window — Compaction + token-cost visualizationhttps://docs.anthropic.com/en/docs/claude-code/* — fallback URL pattern; redirects to code.claude.com since the 2026 doc migration.~/.claude/skills/extend-agent/SKILL.md snapshot — fallback only when the live docs are unreachable.If the WebFetch returns "redirect detected," follow the redirect URL once. If both 404, the doc has moved — search https://www.anthropic.com/news for the latest Claude Code post.
The fields you'd use change quarterly. Always re-confirm:
name, description, disable-model-invocation, user-invocable, context: fork, allowed-tools, plus any new fields). Pay attention to context-cost rules (which fields load description: into context, which don't).model, tools, memory, skills, maxTurns, isolation). Default model when none is specified.model: ...? The lineup churns most often. Check anthropic.com/news for the latest.command / http / mcp_tool / prompt / agent (experimental) — verify the type you want exists.description: ≤200 chars; progressive disclosure to references/ for detail.After verifying knobs the new extension needs, do a second pass: scan the live doc for capabilities NOT YET reflected in this SKILL.md, related skills, or the user's ~/.claude/agents/ / ~/.claude/skills/ configs. Report any "new since snapshot" features as recommendations the user might want to adopt — even if not directly relevant to the current extension. Examples to look for each run:
PostToolBatch, TaskCreated, PostCompact series didn't exist in the snapshot).prompt, agent hook types — verify which experimental flags are needed).metadata.allowed-tools arrived in the AgentSkills standard).For each gap, report: feature name, doc URL, one-line value-prop, and whether it's worth adopting now or filing as a follow-up. The user decides. The skill author surfaces.
Treat the live doc as authoritative. The snapshot is hand-off context, not source of truth. Open a follow-up note (memory or a comment in the SKILL.md) so the next /strategic-compact run catches the drift.
3-4 WebFetch calls (~10-30k tokens depending on doc size — they're large pages). It pays for itself by preventing a session-long detour fixing a wrong field name or recommending a removed feature.
</freshness_check>
<essential_principles>
~/.claude/skills/strategic-compact/references/promotion-quality-gates.md §Gate 1 for the full 5-criterion checklist.| Type | Claude Code | Cursor | Gemini CLI | Copilot | Purpose |
|---|---|---|---|---|---|
| Skill | skills/<name>/SKILL.md | .cursor/rules/<name>.mdc | N/A (use GEMINI.md) | N/A (use instructions) | Domain knowledge + workflows |
| Command | commands/<name>.md | .cursor/rules/<name>.mdc | .gemini/commands/<name>.toml | N/A | Quick action shortcuts |
| Hook | settings.json hooks | alwaysApply: true rules | settings.json hooks | N/A | Event-driven automation |
| Subagent | agents/<name>.md | .cursor/agents/<name>.md | N/A (use MCP/extensions) | N/A | Specialist AI instances |
| Rule | .claude/rules/<name>.md | .cursor/rules/<name>.mdc | GEMINI.md sections | .github/instructions/*.instructions.md | Coding conventions |
---
name: skill-name # Required: unique identifier
description: What and when to use # Required: Claude reads this to decide invocation
disable-model-invocation: true # Optional: only user can invoke via /name (zero context cost)
user-invocable: false # Optional: hides from / menu, Claude auto-invokes only
context: fork # Optional: runs in isolated subagent context
agent: general-purpose # Optional: which agent type for forked context
allowed-tools: Read, Grep, Glob # Optional: restrict available tools
---
Context cost rules:
disable-model-invocation: true → description NOT in context (zero cost, user-only)user-invocable: false → description IN context (Claude auto-invokes)---
description: What it does and when it applies
globs: ["**/*.py"] # File patterns (empty = on-demand)
alwaysApply: false # true = always in context
---
---
applyTo: "**/*.py,**/*.ts" # Glob patterns for file scope
excludeAgent: "code-review" # Optional: exclude from specific agent
---
---
name: agent-name # Required
description: When to use # Required
tools: Read, Grep, Glob, Bash # Optional: restrict tool access
model: sonnet # Optional: sonnet/opus/haiku
memory: user # Optional: persistent cross-session learning
skills: # Optional: preload skills at startup
- testing
- security
maxTurns: 10 # Optional: limit agent turns
isolation: worktree # Optional: isolated git worktree
---
description = "What this command does"
prompt = "The prompt to send when invoked"
| Platform | Field | Format |
|---|---|---|
| Claude Code | paths: | ["**/test_*", "**/*.spec.*"] |
| Cursor | globs: | ["**/test_*", "**/*.spec.*"] |
| Copilot | applyTo: | "**/test_*,**/*.spec.*" |
| Gemini CLI | N/A | Context files loaded by directory hierarchy |
</essential_principles>
What would you like to create?Wait for response before proceeding.
| Choice | Instructions | |--------|-------------| | 1, "skill", "rule", "mdc" | Read `workflows/create-simple-skill.md` | | 2, "command", "slash" | See `` below | | 3, "hook", "automation" | See `` below | | 4, "subagent", "agent" | Read `workflows/create-subagent.md` |<create_command>
Claude Code (.claude/commands/<name>.md):
---
description: What this command does (appears in /help)
argument-hint: [optional-arg]
allowed-tools: Bash(git add:*), Bash(git commit:*) # Optional
# Note: allowed-tools matches per-pipeline-stage. `Bash(grep:*)` does NOT
# cover `grep ... | head` — the `head` tail is classified separately.
# Enumerate every stage or wrap the pipeline in a script. See
# `~/.claude/skills/strategic-compact/references/claude-code-best-practices.md`
# §Settings keys for full rationale.
---
<objective>
What to accomplish. Use $ARGUMENTS if taking user input.
</objective>
<context>
Current status: !`git status`
Relevant file: @package.json
</context>
<process>
1. Step one
2. Step two
3. Verify
</process>
<success_criteria>
Definition of done.
</success_criteria>
Install: cp command.md ~/.claude/commands/
Invoke: /command-name [args]
Cursor (.cursor/rules/<name>.mdc with alwaysApply: false):
---
description: When asked to [action], follow this workflow
globs: []
alwaysApply: false
---
<process>
1. Step one
2. Step two
</process>
Key difference: Cursor has no / invocation — the rule activates when the user describes the action.
Arguments:
$ARGUMENTS — all args as one string: /fix-issue 123 → $ARGUMENTS = "123"$1, $2, $3 — positional: /review-pr 456 high → $1=456, $2=high</create_command>
<create_hook>
Hooks are event-driven automation in .claude/hooks.json.
Hook events:
| Event | When | Blocking? |
|---|---|---|
PreToolUse | Before tool runs | Yes |
PostToolUse | After tool runs | No |
UserPromptSubmit | User submits prompt | Yes |
Stop | Agent tries to stop | Yes |
SubagentStop | Subagent tries to stop | Yes |
SessionStart | Session begins | No |
SessionEnd | Session ends | No |
PreCompact | Before context compaction | Yes |
Notification | Claude needs input | No |
Command hook template:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/my-hook.sh",
"timeout": 10000
}
]
}
]
}
}
Blocking hook output (stdout from your script):
{"decision": "block", "reason": "Why this was blocked"}
Prompt hook template (LLM evaluates instead of a script):
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{"type": "prompt", "prompt": "Is this command safe: $ARGUMENTS\nReturn JSON: {\"decision\": \"approve\" or \"block\", \"reason\": \"...\"}"}]
}]
}
}
Use prompt type when decision requires reasoning; command type for deterministic checks.
Test hooks with: claude --debug
Matchers:
"Bash" → Exact tool name
"Write|Edit" → Multiple tools (regex OR)
"mcp__.*" → All MCP tools
(omit matcher) → Fires for all tools
Cursor equivalent: No native hook system. Use alwaysApply: true rules:
---
alwaysApply: true
---
NEVER run: rm -rf, git push --force, DROP TABLE.
ALWAYS check git status before committing.
See skills/security/hooks/ for working hook script examples.
</create_hook>
<create_skill_and_subagent_notes>
Skill design patterns:
SKILL.md fileworkflows/, references/, templates/ subdirsreferences/ subdirectory!`cmd`) runs under the invocation's working-directory sandbox. Direct reads of files outside the current project (grep ~/.claude/settings.json, cat ~/.claude/some-file) are BLOCKED at every invocation — the sandbox rejects the read before the skill body loads, breaking the skill in every session. Safe: ls ~/.claude/<subdir>/ (directory listing, no file content), date, git status. Unsafe: any grep/cat/find targeting a specific file under $HOME outside the working project. Fix: move the read into a script under ~/.claude/skills/<name>/scripts/* and pre-approve the scripts dir via allowed-tools: Bash(bash ~/.claude/skills/<name>/scripts/*). That single allow-tool grants the script's own read access without triggering the grep sandbox.Subagent execution model — critical constraints:
AskUserQuestion or wait for user inputdescription field) or explicitly via the Task tool.claude/agents/) override user subagents (~/.claude/agents/) on name conflictmemory: user enables persistent learning at ~/.claude/agent-memory/<name>/skills: preloading injects full skill content at startup (no need for inline "read skills/X/SKILL.md")When to use subagents proactively:
| Situation | Agent | Why |
|---|---|---|
| Complex feature | planner | Break down before building |
| Code just written | reviewer | Catch issues immediately |
| New feature or bug fix | tester | Tests alongside code |
| Architecture decision | architect | Design before implementation |
| Security-sensitive code | security | Audit before commit |
| Database work | db-expert | Schema and query optimization |
Always launch independent agents in parallel when possible.
</create_skill_and_subagent_notes>
<reference_index>
references/skill-structure.md — Complete skill patterns and XML tagsreferences/cursor-format.md — Cursor .mdc format in depthreferences/core-principles.md — Prompting principles for all extension types
</reference_index><workflows_index>
| Workflow | Purpose |
|---|---|
workflows/create-simple-skill.md | Build a single-file skill or a complex router skill with subdirectories |
workflows/convert-to-cursor.md | Transform a SKILL.md to Cursor .mdc format |
workflows/create-subagent.md | Build a specialist agent for Claude Code or Cursor |
| </workflows_index> |
<scanner_skill_pattern> When designing a skill that scans across many targets (skills, files, PRs, test failures, comments, ...) and proposes per-target actions, the skill body MUST:
[i/N] with rationale and proposed action.skip-skill / apply all shortcuts for batch decisions.Anti-pattern: returning one match with "I found this" — the user can't see what you skipped, can't redirect priority, and trusts a partial scan as complete.
Repeat-use as a smell: if the user invokes the same skill 3+ times within one session/task, the skill body is probably under-specified. Make sure new scanner skills produce a complete pass per invocation; one call should fully discharge the user's intent. </scanner_skill_pattern>
<success_criteria>