Agent authoring

From majiayu000/claude-skill-registry-data · View interactive version

Agent authoring is an AI agent skill from the GitHub repository majiayu000/claude-skill-registry-data. Guide for authoring specialized AI agents. Use when creating, updating, or improving agents, choosing models, defining focus areas, configuring tools, or learning agent best practices.

How to use this skill

Skill file

Reference Files

Advanced agent authoring guidance:


About Agents

Agents are specialized AI assistants that run in separate subprocesses with focused expertise. They have:

When to use agents:

Core Principles

1. Clear Focus Areas

Focus areas define what the agent is expert in. They should be:

Specific, not generic:

Concrete, with examples:

5-15 focus areas that cover the agent's expertise comprehensively.

Example from evaluator agent:

## Focus Areas

- YAML Frontmatter Validation
- Markdown Structure
- Tool Permissions
- Description Quality
- File Organization
- Progressive Disclosure
- Integration Patterns

2. Model Selection (Keep It Simple)

Sonnet (default choice for most agents):

Haiku (for simple, fast tasks):

Opus (for complex reasoning):

Decision guide:

  1. Start with Sonnet
  2. Switch to Haiku if agent is simple read-only analyzer
  3. Only use Opus if task genuinely requires highest capability

3. Tool Restrictions

Why restrict tools:

Common tool patterns:

Read-only analyzer:

allowed_tools:
  - Read
  - Glob
  - Grep
  - Bash

Examples: evaluator, audit-skill

Code generator/modifier:

allowed_tools:
  - Read
  - Edit
  - Write
  - Grep
  - Glob
  - Bash

Examples: test-runner

Minimal/focused:

allowed_tools:
  - Read
  - AskUserQuestion

Example: When agent only needs to read and ask questions

If unspecified: Agent inherits all tools from parent (usually not desired)

4. Permission Modes (Common Ones)

default (most common):

acceptEdits (for editing workflows):

plan (for planning agents):

Most agents use default - only use others when you have a specific workflow need.

5. Agent Hooks

Agent hooks are lifecycle hooks defined in YAML frontmatter, scoped to that specific agent.

When to use agent hooks:

When to use settings.json hooks instead:

Available events:

| Event | Trigger | Use Case |

| ------------- | ---------------------- | ----------------------------- |

| PreToolUse | Before agent uses tool | Validation, blocking, logging |

| PostToolUse | After tool completes | Formatting, notifications |

| Stop | Agent finishes | Cleanup, notifications |

Configuration syntax:

---
name: code-reviewer
description: Review code with automatic linting
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: "./scripts/validate-command.sh"
  PostToolUse:
    - matcher: "Edit|Write"
      hooks:
        - type: command
          command: "./scripts/run-linter.sh"
          timeout: 10
---

Key points:

Agent Design Patterns

Three proven patterns for building effective agents. Each pattern includes complete templates you can copy and customize.

📄 See design-patterns.md for detailed templates

Quick overview:

  1. Read-Only Analyzer - For auditing, evaluation, reporting (Haiku/Sonnet + read-only tools)
  2. Code Generator/Modifier - For creating/editing code (Sonnet + Read/Edit/Write/Bash)
  3. Workflow Orchestrator - For multi-step coordination (Sonnet + Task tool)

Resource Organization

File Structure

Per Claude Code specification, agents are single files only:

agents/
├── code-reviewer.md           # Single file agent
├── bash-expert.md             # Single file agent
└── security-auditor.md        # Single file agent

No subdirectories or reference files supported.

Agent vs Skill

| Need | Use |

| ---------------------------------------- | ----------------------------- |

| Reference files / progressive disclosure | Skill |

| Single-file focused capability | Agent |

| Large documentation (>500 lines) | Skill (can split content) |

If you need reference files, convert to a skill instead:

skills/evaluator/
├── SKILL.md                   # Main skill file
├── evaluation-criteria.md     # Reference file
└── examples.md                # Reference file

📄 See ~/.claude/docs/agent-vs-skill-structure.md for details

Keeping Agents Focused

Since agents must be single files:

Agent Creation Process

Step 1: Define Purpose and Scope

Start by clarifying:

Questions to ask:

Use AskUserQuestion to clarify ambiguities before proceeding.

Check for existing agents:

ls -la ~/.claude/agents/

Look for similar agents that might overlap.

Step 2: Choose Model and Tools

Model selection:

  1. Default to Sonnet for most agents
  2. Use Haiku if it's a simple read-only analyzer
  3. Only use Opus if complexity genuinely requires it

Tool selection:

  1. List what the agent actually needs to do
  2. Map needs to minimal tool set
  3. Use restrictive set from design patterns above
  4. Don't grant tools "just in case"

Permission mode:

Step 3: Write Focus Areas

Guidelines:

Good examples (from evaluator):

Bad examples:

Step 4: Define Approach/Methodology

This section explains HOW the agent works:

Include:

Example from evaluator:

## Evaluation Framework

### Correctness Criteria

- YAML frontmatter with required fields
- Valid model value
- Name matches filename
  ...

## Evaluation Process

### Step 1: Identify Extension Type

...

### Step 2: Apply Type-Specific Validation

...

Step 5: Write Description

Requirements:

Formula: [What it does] for [use cases]. Expert/Use when [triggers]. [Key features]

Good example:

description: Master of defensive Bash scripting for production automation, CI/CD pipelines, and system utilities. Expert in safe, portable, and testable shell scripts.

Bad example:

description: Helps with bash scripts

Step 6: Create the Agent File

File location: ~/.claude/agents/agent-name.md

Filename should match name in frontmatter.

Basic structure:

---
name: agent-name
description: [comprehensive description with triggers]
model: sonnet
allowed_tools:
  - Read
  - [other tools]
---

## Focus Areas

- [Specific area 1]
- [Specific area 2]
  ...

## Approach

[How the agent works, methodologies, processes]

## [Optional Additional Sections]

[Examples, best practices, output formats, etc.]

Step 7: Test the Agent

Test invocation:

  1. Try invoking the agent in a conversation
  2. Verify it has access to specified tools
  3. Check that focus areas guide its behavior
  4. Ensure description triggers correctly

Validate with /audit-agent:

/audit-agent agent-name

This will check:

Agents vs Skills vs Commands

Choosing the right customization type is critical. Each has distinct characteristics and use cases.

📄 See agent-decision-guide.md for agent-specific decision framework

📄 See when-to-use-what.md for detailed decision guide (shared)

Quick guide:

Common Mistakes to Avoid

  1. Vague focus areas - "Python expert" instead of "FastAPI with SQLAlchemy and pytest"
  2. Wrong model - Using Opus when Sonnet would work fine
  3. Too permissive tools - Granting all tools when only Read/Grep needed
  4. Missing approach section - Not explaining HOW the agent works
  5. Poor description - Too short or doesn't include trigger scenarios
  6. Name mismatch - Frontmatter name doesn't match filename
  7. Overlapping agents - Creating agent that duplicates existing one
  8. No tool restrictions - Not specifying allowed_tools (inherits all)

Examples from Existing Agents

Real-world examples showing what makes a good agent. Each example is analyzed to explain why it works well.

📄 See examples.md for detailed analysis

Examples covered:

  1. evaluator - Read-only evaluator pattern
  2. test-runner - Test runner with reporting pattern

Each example includes the full frontmatter, focus areas, and analysis of what makes it effective.

Tips for Success

  1. Start with an existing agent as template - Copy structure from similar agent
  2. Be specific in focus areas - Concrete details over generic statements
  3. Test early - Create minimal agent and test before adding details
  4. Use /audit-agent - Catch issues early
  5. Check for overlaps - Don't duplicate existing agents
  6. Document the approach - Explain HOW the agent works
  7. Keep tools minimal - Only grant what's needed
  8. Write good description - Include what, when, and key features
  9. Iterate based on usage - Refine after real-world testing
  10. Follow naming conventions - Use kebab-case, match filename to name

Reference to Standards

For detailed standards and validation:

See audit-coordinator skill for comprehensive standards.

Related Skills

This skill is part of the authoring skill family:

For validation, use the corresponding audit skills:

Quick Start Checklist

Creating a new agent:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.