代理创建者
- 作者仓库星标 0
- 作者仓库 claude-code
- 领域
- 设计与多媒体
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 85 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @agdev · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- Windows
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。;上游仓库已 190 天未更新,可能与最新智能体行为不一致。
第 1 步:明确目的
在创建之前,先回答:这个代理解决什么具体问题?克劳德什么时候应该自动调用这个代理?这与现有代理有何不同?这是否需要隔离,或者技能就足够了?
第2步:设计描述
编写全面的描述: 从角色/能力声明开始 为强触发器添加“必须使用”或“主动使用” 包括特定场景和触发短语 为复杂场景添加使用 XML 标签的示例
第三步:选择工具
确定所需的最少工具: 列出代理必须执行的所有操作 将操作映射到特定工具 删除并非绝对必要的任何工具 考虑安全隐患
第四步:选择型号
根据任务复杂性进行选择: 简单/快速任务 → `haiku` 标准任务 → `sonnet` 或忽略(默认) 复杂推理 → `opus`
第5步:编写系统提示符
构造提示体:
第 6 步:定义边界
如果代理的范围有限,请添加明确的边界:
# Agent Creator
Expert guidance for creating effective Claude Code agents following best practices.
## About Agents
Agents are specialized subprocesses that handle complex tasks autonomously with **isolated context windows**. They extend Claude's capabilities by providing focused expertise, specific tool access, and appropriate model selection for different task types.
### Agents vs Skills
| Aspect | Agents | Skills |
|--------|--------|--------|
| **Context** | Isolated context window | Shared with main conversation |
| **Purpose** | Autonomous task execution | Procedural knowledge & guidance |
| **Model** | Can specify different model | Uses current model |
| **Tools** | Can restrict/expand tool access | Uses available tools |
| **Use when** | Task needs isolation, different capabilities, or parallel execution | Task benefits from guidance staying in current context |
**Choose agents when:**
- Task benefits from isolated context (clean slate)
- Different model is optimal (haiku for speed, opus for reasoning)
- Tool access should be restricted for security
- Tasks can run in parallel
**Choose skills when:**
- Knowledge should stay in current conversation
- Guidance benefits from seeing full context
- No special tool/model requirements
## Agent Architecture
### File Structure
Agents are Markdown files with YAML frontmatter stored in:
- **Project agents**: `.claude/agents/` (highest priority)
- **User agents**: `~/.claude/agents/` (all projects)
### Configuration Format
```yaml
---
name: agent-identifier # Required: lowercase, hyphens only
description: When and why... # Required: PRIMARY TRIGGER MECHANISM
tools: Tool1, Tool2, Tool3 # Optional: restrict/specify tools
model: sonnet # Optional: sonnet, opus, haiku
skills: skill1, skill2 # Optional: auto-load skills
color: blue # Optional: UI indicator
---
[Agent system prompt here - Markdown instructions]
```
### Configuration Fields
| Field | Required | Details |
|-------|----------|---------|
| `name` | Yes | Lowercase letters and hyphens only (e.g., `code-reviewer`) |
| `description` | Yes | **PRIMARY TRIGGERING MECHANISM** - determines when agent is invoked |
| `tools` | No | Comma-separated list; omit to inherit all tools |
| `model` | No | `haiku` (fast), `sonnet` (balanced), `opus` (reasoning) |
| `skills` | No | Skills to auto-load when agent invokes |
| `color` | No | UI color indicator |
## Core Principles
### 1. Single-Purpose Focus
Create focused, single-responsibility agents:
- One clear job per agent
- Better composability and predictability
- Easier to debug and maintain
### 2. Description is Everything
The `description` field is the **PRIMARY TRIGGERING MECHANISM**. Include:
- WHAT the agent does
- WHEN to use it (trigger scenarios)
- Specific examples in angle brackets
**Pattern:**
```yaml
description: [Role/capability]. MUST BE USED for [specific scenarios]. [Additional context]. Examples: "[trigger phrase 1]", "[trigger phrase 2]"
```
### 3. Minimal Viable Toolset
Grant only necessary tools:
- **Read-only agents**: Glob, Grep, Read, LS
- **Analysis agents**: Add WebFetch, WebSearch
- **Planning agents**: Add Write, Edit, TodoWrite
- **Implementation agents**: Add Bash, Task
**Performance impact:**
- 3-5 tools: ~2-5k tokens
- 7-8 tools: ~7-10k tokens
- 15+ tools: 15-25k tokens (avoid)
### 4. Appropriate Model Selection
- **Haiku**: Fast, lightweight tasks (exploration, simple analysis)
- **Sonnet**: Balanced tasks (orchestration, validation, general work)
- **Opus**: Complex reasoning (planning, architecture, research)
## Agent Creation Process
### Step 1: Define Purpose
Before creating, answer:
1. What specific problem does this agent solve?
2. When should Claude automatically invoke this agent?
3. What makes this different from existing agents?
4. Does this need isolation, or would a skill suffice?
### Step 2: Design Description
Write a comprehensive description:
1. Start with role/capability statement
2. Add "MUST BE USED" or "use PROACTIVELY" for strong triggers
3. Include specific scenarios and trigger phrases
4. Add examples using XML tags for complex scenarios
### Step 3: Select Tools
Determine minimum tools needed:
1. List all operations the agent must perform
2. Map operations to specific tools
3. Remove any tools not strictly necessary
4. Consider security implications
### Step 4: Choose Model
Select based on task complexity:
- Simple/fast tasks → `haiku`
- Standard tasks → `sonnet` or omit (default)
- Complex reasoning → `opus`
### Step 5: Write System Prompt
Structure the prompt body:
```markdown
# [Role Title]
[One-sentence mission statement]
## Core Principles
- [Principle 1]: [Brief explanation]
- [Principle 2]: [Brief explanation]
## Responsibilities / Methodology
1. [Step/responsibility 1]
2. [Step/responsibility 2]
## [Workflow/Process] (if multi-step)
### Step 1: [Name]
[Instructions]
## Quality Standards / Output Format
[Checklists, criteria, format requirements]
## Constraints (if critical)
- [What agent MUST NOT do]
- [Boundaries and limitations]
```
### Step 6: Define Boundaries
Add explicit boundaries if agent has limited scope:
```markdown
## YOUR ROLE ENDS HERE
**CRITICAL BOUNDARY**: You are strictly a [role]. Once you have [completed work]:
- Your work is COMPLETE
- DO NOT [prohibited action 1]
- DO NOT [prohibited action 2]
```
## Prompt Engineering Best Practices
### Use Imperative Form
- "Identify issues" not "You should identify"
- "Generate report" not "The report should be generated"
### Strong Emphasis Markers
- **MUST**, **NEVER**, **ALWAYS**, **CRITICAL** for non-negotiables
- Bold or capitalize critical constraints
- Use strategically, not everywhere
### Include Examples
- Good vs Bad examples (Use checkmarks/X marks)
- Concrete user scenarios
- Before/after for transformations
### Be Specific, Not Vague
- "Test min/max values, zero, negative" not "test edge cases"
- "Check for SQL injection, XSS, path traversal" not "check security"
- Include decision criteria and thresholds
## Common Pitfalls to Avoid
### Over-Engineering
- Creating 15+ tool agents with 30k token prompts
- One mega-agent instead of composable focused agents
- Adding features "just in case"
**Solution:** Start lightweight (<3k tokens, 3-5 tools), expand based on need
### Vague Descriptions
- "Helps with coding" - too generic
- Missing "when to use" information
- No concrete trigger examples
**Solution:** Specific triggers, scenarios, and examples
### Tool Overload
- Giving all tools "just in case"
- Read-only agents with Write/Bash access
- Security risk and performance hit
**Solution:** Minimal viable toolset per agent purpose
### Missing Boundaries
- Agent scope creeps during execution
- No clear "done" criteria
- Agent attempts tasks outside its role
**Solution:** Explicit "YOUR ROLE ENDS HERE" section for bounded agents
### Ignoring Token Budget
- Verbose explanations Claude already knows
- Repeated information
- Unnecessary examples
**Solution:** Challenge each paragraph - "Does this justify its token cost?"
## Integration with Skills
When an agent needs domain expertise, use skills:
```yaml
---
name: specialized-agent
skills: domain-skill, helper-skill
---
```
**When to create an accompanying skill:**
- Agent needs substantial domain knowledge
- Knowledge is reusable across multiple agents
- Information would bloat agent prompt
**Use the skill-creator skill** to create accompanying skills:
```
Invoke skill: skill-creator
```
## Quality Checklist
Before finalizing an agent:
- [ ] **Name**: Lowercase with hyphens, descriptive
- [ ] **Description**: Includes WHAT, WHEN, and examples
- [ ] **Tools**: Minimal viable set for the task
- [ ] **Model**: Appropriate for task complexity
- [ ] **Prompt**: Follows structure (role → principles → methodology → standards)
- [ ] **Boundaries**: Clear scope and "done" criteria (if bounded)
- [ ] **Token efficiency**: <5k words for most agents
- [ ] **Examples**: Concrete scenarios in description or prompt
- [ ] **No overlap**: Doesn't duplicate existing agent functionality
## Example: Well-Designed Agent
```yaml
---
name: code-reviewer
description: Expert code review specialist. MUST BE USED when reviewing pull requests, code changes, or architecture decisions. Focuses on security, performance, maintainability, and best practices. Examples: "Review this PR", "Check this implementation for issues", "Review the changes in feature branch"
tools: Glob, Grep, Read, LS, WebSearch
model: sonnet
color: yellow
---
# Code Review Specialist
You are an expert code reviewer focused on identifying issues that impact security, performance, and maintainability.
## Review Priorities
1. **Security**: Injection vulnerabilities, auth issues, data exposure
2. **Performance**: O(n²) operations, memory leaks, unnecessary computation
3. **Maintainability**: Code clarity, naming, separation of concerns
4. **Best Practices**: Framework conventions, error handling, testing
## Review Process
1. Understand the change context (what problem is being solved)
2. Review for security vulnerabilities first
3. Check performance implications
4. Assess code quality and maintainability
5. Verify test coverage
## Output Format
For each issue found:
- **Severity**: Critical/High/Medium/Low
- **Location**: file:line
- **Issue**: Clear description
- **Recommendation**: Specific fix suggestion
## YOUR ROLE ENDS HERE
You are strictly a reviewer. After completing review:
- Your work is COMPLETE
- DO NOT implement fixes
- DO NOT modify code
```
## Resources
- See `references/prompt-patterns.md` for advanced prompt engineering patterns
- Use `skill-creator` skill when agent needs accompanying skills
章节与文件索引
按说明文件中的顺序排列。
关于代理商
特工与技能
文件结构
配置字段
1.单一目的焦点
文件/命令 -> .claude/agents/ · ~/.claude/agents/ · name · code-reviewer · description · tools · model · haiku
内容校验值 -> 4ef638218f90
当前原文的自动摘译,尚未人工审校。
关于代理商
代理是专门的子流程,可以通过隔离的上下文窗口自主处理复杂的任务。他们通过提供专注的专业知识、特定的工具访问以及针对不同任务类型的适当模型选择来扩展 Claude 的能力。
特工与技能
方面 · 代理 · 技能 上下文 · 独立的上下文窗口 · 与主对话共享 目的 · 自主任务执行 · 程序知识和指导 模型 · 可以指定不同的模型 · 使用当前模型 工具 · 可以限制/扩展工具访问 · 使用可用工具
文件结构
代理是带有 YAML frontmatter 的 Markdown 文件,存储在: 项目代理:
.claude/agents/(最高优先级) 用户代理:~/.claude/agents/(所有项目)配置字段
字段 · 必填 · 详细信息
name· 是 · 仅小写字母和连字符(例如,code-reviewer)description· 是 · 主要触发机制 - 确定何时调用代理tools· 否 · 逗号分隔列表;省略继承所有工具model·否·haiku(快速),sonnet(平衡),opus(推理)1.单一目的焦点
创建专注的单一职责代理:每个代理一项明确的工作 更好的可组合性和可预测性 更易于调试和维护