commit cbbf141e75e3126bfbeb2cf8af2ef6b1e3db3c7c Author: Zhongwei Li Date: Sun Nov 30 09:07:30 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..79901cb --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "claude", + "description": "Claude Development Plugin", + "version": "1.0.3", + "author": { + "name": "Meng Yan", + "email": "myan@redhat.com" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e2e2152 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# claude + +Claude Development Plugin diff --git a/commands/create-command.md b/commands/create-command.md new file mode 100644 index 0000000..644627a --- /dev/null +++ b/commands/create-command.md @@ -0,0 +1,200 @@ +--- +argument-hint: "[category/name] [--update] or leave empty for interactive creation" +description: "Extract and save current session workflow as a reusable slash command" +allowed-tools: [Write, Edit, Glob, Read, Bash, AskUserQuestion] +--- + +Extract and save the current or most recent session workflow as a reusable slash command file. Supports creating new commands, updating existing ones, and interactive guided creation. + +## Usage Examples + +- `git/draft-pr` - Create new command from recent workflow +- `git/commit-push --update` - Update existing command with improvements +- Leave empty - Interactive mode with guided questions + +## Command Creation Process + +1. **Determine Mode**: + - If `--update` flag: Update existing command + - If command name provided: Auto mode - analyze recent workflow + - If no arguments: Interactive mode - ask guided questions + +2. **Analyze Workflow**: Extract recent session patterns, tool usage, and command sequences + +3. **Generate Command File**: + - Create at `~/.claude/commands/category/name.md` + - Add YAML frontmatter with argument-hint, description, allowed-tools + - Write implementation steps consolidating workflow actions + - Include usage examples and notes + +4. **Update Mode** (when using `--update`): + - Read existing command file + - Preserve metadata unless workflow significantly changed + - Merge or enhance implementation steps + - Add newly used tools to allowed-tools list + +## Naming & Location + +**Format**: `category/name` → command file path + +**Personal Commands**: `~/.claude/commands/category/name.md` +- Available across all projects +- For individual workflows + +**Project Commands**: `./.claude/commands/category/name.md` +- Shared with team via git +- For project-specific workflows + +**Examples**: +- `git/draft-pr` → `~/.claude/commands/git/draft-pr.md` (personal) +- `docker/build` → `./.claude/commands/docker/build.md` (project) +- `jira/clone-issue` → `~/.claude/commands/jira/clone-issue.md` (personal) + +**Auto-detection** (interactive mode with no name): +- Git operations → `git/workflow` +- Node/npm → `node/workflow` +- Docker → `docker/workflow` +- Test operations → `test/workflow` +- Jira → `jira/workflow` +- AWS → `aws/workflow` + +## Command File Structure + +```markdown +--- +argument-hint: [describe expected arguments and defaults] +description: Brief action-oriented description +allowed-tools: [Bash, Read, Write, Edit, etc.] +--- + +Brief description of command purpose and when to use it. + +## Implementation Steps + +1. **Major Action**: Description of what to do (consolidate related actions) +2. **Next Step**: Clear actionable instruction +3. **Final Step**: Verification or cleanup + +## Usage Examples + +- `/category/name arg1` - Example scenario +- `/category/name --flag` - Another scenario + +## Notes +- Prerequisites or dependencies +- Related commands +- Important considerations +``` + +## Interactive Questions + +When in interactive mode, ask: + +1. **Purpose**: What should this command do? + - Automate git operations + - Run tests or builds + - Manage external services (Jira, AWS, Docker) + - Code generation or scaffolding + +2. **Scope**: Where should this command be available? + - Personal use only (save to ~/.claude/commands/) + - Share with team (save to ./.claude/commands/ for git tracking) + +3. **Tools**: Which tools are needed? (multi-select) + - File operations (Read, Write, Edit, Glob) + - Shell commands (Bash) + - User interaction (AskUserQuestion) + - All tools (no restrictions) + +4. **Arguments**: How should arguments be handled? + - All as single value + - Multiple positional arguments + - With default values + - No arguments needed + +## Workflow Extraction + +When analyzing recent workflow: + +1. **Track Tool Usage**: Identify frequently used tools +2. **Find Patterns**: Detect repeated action sequences +3. **Extract Commands**: Capture successful bash commands and operations +4. **Consolidate Steps**: Group micro-actions into major steps (avoid excessive detail) +5. **Infer Metadata**: Set appropriate allowed-tools based on actual usage + +## Update Mode Details + +When updating with `--update` flag: + +1. Preserve original description and argument-hint unless workflow changed significantly +2. Merge new steps with existing implementation steps +3. Add new tools to allowed-tools if used in recent workflow +4. Enhance usage examples with recent successful executions +5. Update notes with lessons learned or edge cases discovered + +## Output Format + +After creation: + +```text +✅ Command created: /category/name + Location: ~/.claude/commands/category/name.md + Tools: [list of allowed-tools] + +🔍 Usage: /category/name [arguments] +``` + +After update: + +```text +✅ Command updated: /category/name + Location: ~/.claude/commands/category/name.md + +🔄 Changes: + - [Summary of what changed] +``` + +## Best Practices + +**Description**: + +- Start with action verb (e.g., "Create", "Run", "Update") +- Keep under 100 characters +- Be specific and clear + +**Implementation Steps**: + +- Consolidate related actions (avoid micro-steps) +- Use descriptive step names +- Mention argument usage naturally in descriptions +- Include verification or error handling + +**Allowed Tools**: + +- Only list tools actually needed +- Omit for unrestricted access +- Use minimal set for security + +## Examples + +```bash +# Interactive creation +/claude:create-command + +# Create from recent git workflow +/claude:create-command git/sync-upstream + +# Update existing command with improvements +/claude:create-command git/commit-push --update + +# Create project-specific test command +/claude:create-command test/e2e-debug +``` + +## Notes + +- Commands expand to full prompts when invoked +- Keep focused on one specific workflow +- Test thoroughly before sharing with team +- Use `--update` to refine based on real usage +- Commands run in current working directory context diff --git a/commands/create-skill.md b/commands/create-skill.md new file mode 100644 index 0000000..8eeecc7 --- /dev/null +++ b/commands/create-skill.md @@ -0,0 +1,280 @@ +--- +argument-hint: [skill-name] or leave empty for interactive creation +description: Create a new Claude skill based on recent session workflow or conversation history +allowed-tools: [Write, Read, Glob, Bash, AskUserQuestion] +--- + +Create a new Claude skill that extends Claude's capabilities through modular instructions and supporting files. Skills are model-invoked (Claude autonomously decides when to use them) based on the description and context. + +## Usage Examples + +- `pdf-extractor` - Create a skill for extracting PDF content +- `api-testing` - Create a skill for API testing workflows +- Leave empty - Interactive mode with guided questions + +## Skill Creation Process + +1. **Determine Mode**: If skill name provided, use auto mode; otherwise, use interactive mode + +2. **Interactive Mode** (no arguments): + - Ask user about the skill's purpose and when it should be used + - Ask what tools/capabilities the skill needs (Read, Write, Bash, etc.) + - Ask if there are specific examples or workflows to include + - Analyze recent conversation history to extract patterns + +3. **Auto Mode** (skill name provided): + - Analyze recent session messages and tool calls + - Extract workflow patterns and common steps + - Identify tools used and create appropriate restrictions + - Generate skill based on detected patterns + +4. **Generate Skill Structure**: + - Create skill directory: `~/.claude/skills/$1/` + - Write `SKILL.md` with YAML frontmatter and instructions + - Optionally create supporting files (`reference.md`, `examples.md`, `scripts/`) + +5. **Verify and Test**: + - Check YAML syntax validity + - Verify file paths are correct (Unix-style forward slashes) + - Confirm skill description is specific and includes activation triggers + +## Skill Types + +**Personal Skills**: `~/.claude/skills/skill-name/` +- Available across all projects +- For individual workflows + +**Project Skills**: `./.claude/skills/skill-name/` +- Shared with team via git +- For project-specific expertise + +## SKILL.md Template Structure + +```yaml +--- +name: skill-name +description: Clear description of WHAT this does AND WHEN to use it. Include specific keywords and triggers for discoverability. +allowed-tools: [List, Of, Tools] # Optional: restrict to specific tools +--- + +# Skill Name + +Brief overview of the skill's purpose. + +## When to Use This Skill + +- Specific scenario 1 +- Specific scenario 2 +- Clear trigger conditions + +## Instructions + +Step-by-step guidance for Claude: + +1. **Step Name**: Detailed description of what to do + - Sub-step or consideration + - Expected outcome + +2. **Next Step**: Continue with clear actions + +## Examples + +### Example 1: [Scenario Name] +``` +[Code or command example] +``` + +### Example 2: [Another Scenario] +``` +[Code or command example] +``` + +## Best Practices + +- Guideline 1 +- Guideline 2 +- Common pitfalls to avoid + +## Tool Usage + +[If applicable, describe how to use specific tools effectively] + +## Output Format + +[If applicable, describe expected output format] +``` + +## Description Best Practices + +**Poor**: "Helps with documents" +**Good**: "Extract text and tables from PDFs, fill forms, merge documents. Use when working with PDF files, document processing, or form automation." + +**Poor**: "Testing tool" +**Good**: "Run automated API tests with request/response validation. Use when testing REST endpoints, validating API responses, or debugging HTTP requests." + +## Interactive Questions + +When in interactive mode, ask: + +1. **Purpose Question**: + - Header: "Skill Purpose" + - Question: "What should this skill help you accomplish?" + - Options: + - "Automate a repetitive task" - Streamline workflows you do often + - "Add domain expertise" - Provide specialized knowledge in a field + - "Integrate external tools" - Connect with APIs, CLIs, or services + - "Improve code quality" - Review, test, or refactor code + +2. **Activation Question**: + - Header: "When to Use" + - Question: "When should Claude automatically invoke this skill?" + - Options: + - "Specific keywords" - Trigger on certain terms or phrases + - "File patterns" - Activate for specific file types/extensions + - "Task context" - Use when user requests certain operations + - "Always available" - Let Claude decide based on context + +3. **Tools Question** (multiSelect: true): + - Header: "Required Tools" + - Question: "Which tools should this skill have access to?" + - Options: + - "File operations" - Read, Write, Edit, Glob + - "Shell commands" - Bash execution + - "Web access" - WebFetch, WebSearch + - "All tools" - No restrictions (don't set allowed-tools) + +4. **Examples Question**: + - Header: "Examples" + - Question: "Should we extract examples from recent conversation?" + - Options: + - "Yes, use recent workflow" - Analyze and extract from history + - "I'll provide examples" - Let me describe specific cases + - "Skip examples for now" - Just create basic structure + - "Include both" - Use history and let me add more + +## Workflow Extraction Logic + +When extracting from recent conversation: + +1. **Identify Tool Patterns**: + - Track frequently used tools (Read, Write, Bash, etc.) + - Note file patterns (e.g., `**/*.py`, `*.md`) + - Extract common commands or operations + +2. **Detect Step Sequences**: + - Find repeated action sequences + - Group related operations together + - Identify decision points or conditions + +3. **Extract Examples**: + - Capture actual commands run + - Include file paths and patterns used + - Preserve successful workflows + +4. **Generate Instructions**: + - Convert patterns into reusable steps + - Replace specific values with placeholders + - Add context and rationale + +## Supporting Files + +Optionally create additional files: + +- `reference.md` - Detailed technical documentation +- `examples.md` - Additional usage examples +- `scripts/` - Utility scripts (Python, Bash, etc.) +- `templates/` - Reusable file templates + +## Validation Checks + +Before finalizing: + +1. **YAML Frontmatter**: + - Valid syntax (proper indentation, quotes) + - Required fields present (name, description) + - Tools list properly formatted + +2. **Description Quality**: + - Includes both WHAT and WHEN + - Contains specific keywords for discoverability + - Avoids vague terms like "helps with" or "tool for" + +3. **Instructions Clarity**: + - Steps are numbered and descriptive + - Examples are concrete and runnable + - Best practices are actionable + +4. **File Paths**: + - Use forward slashes (Unix style) + - Absolute paths when needed + - Verify directory exists + +## Output Format + +After creation, provide: + +``` +✅ Skill created successfully: skill-name + Location: ~/.claude/skills/skill-name/ + Files created: + - SKILL.md + - [reference.md if applicable] + - [examples.md if applicable] + +📝 Next Steps: + 1. Review the skill description for clarity + 2. Test the skill by triggering its use case + 3. Refine based on actual usage + 4. Consider adding to project if team-relevant + +🔍 To use this skill: + Just mention the use case naturally, and Claude will invoke it automatically + Example: "Help me [skill use case]" +``` + +## Notes + +- Skills are invoked automatically by Claude based on context, not by user commands +- Keep skills focused on ONE specific capability for better discoverability +- Test skills with team members before sharing project skills +- Use `allowed-tools` to restrict capabilities and improve security +- Skills can include scripts in any language (Python, Bash, JavaScript, etc.) +- Skills are loaded dynamically - no restart needed after creation + +## Examples + +```bash +# Interactive mode - guided creation +/claude:create-skill + +# Auto mode - extract from recent PDF work +/claude:create-skill pdf-processor + +# Auto mode - create testing skill +/claude:create-skill api-integration-tester + +# Auto mode - create from Jira workflow +/claude:create-skill jira-automation +``` + +## Debugging Skills + +If Claude doesn't use your skill: + +1. Make description more specific with concrete keywords +2. Verify file exists at correct path: `ls -la ~/.claude/skills/skill-name/` +3. Check YAML syntax: `head -20 ~/.claude/skills/skill-name/SKILL.md` +4. Ensure skills don't overlap in scope +5. Test with explicit mention: "Use the [skill-name] skill to..." + +## Skill Categories + +Common skill categories to consider: + +- **Document Processing**: PDF, DOCX, XLSX, PPTX manipulation +- **Testing & QA**: Automated testing, API validation, debugging +- **Integration**: External API/CLI integration, webhook handling +- **Code Quality**: Linting, formatting, review automation +- **Workflow Automation**: Git operations, CI/CD, deployment +- **Domain Expertise**: Security auditing, performance optimization, accessibility +- **Communication**: Report generation, documentation, status updates diff --git a/commands/create-subagent.md b/commands/create-subagent.md new file mode 100644 index 0000000..2dd6c3f --- /dev/null +++ b/commands/create-subagent.md @@ -0,0 +1,441 @@ +--- +argument-hint: [subagent-name] or leave empty for interactive creation +description: Create a new Claude subagent based on recent session workflow or conversation history +allowed-tools: [Write, Read, Glob, Bash, AskUserQuestion, Grep] +--- + +Create a new Claude subagent - a specialized AI assistant with its own context window and custom configuration. Subagents are automatically invoked by Claude based on task context or can be explicitly requested. + +## Usage Examples + +- `code-reviewer` - Create a code review specialist subagent +- `api-tester` - Create an API testing subagent +- `spec-analyst` - Create a requirements analysis subagent +- Leave empty - Interactive mode with guided questions + +## Subagent Creation Process + +1. **Determine Mode**: If subagent name provided, use auto mode; otherwise, use interactive mode + +2. **Interactive Mode** (no arguments): + - Ask user about the subagent's role and specialization + - Ask what tasks/scenarios should trigger this subagent + - Ask what tools/capabilities the subagent needs + - Ask what model to use (sonnet, opus, haiku, or inherit) + - Analyze recent conversation history to extract workflow patterns + +3. **Auto Mode** (subagent name provided): + - Analyze recent session messages and tool calls + - Extract workflow patterns, common steps, and decision points + - Identify tools used frequently in the workflow + - Detect domain/context from file patterns and commands + - Generate subagent based on detected patterns + +4. **Generate Subagent File**: + - Create file: `~/.claude/agents/$1.md` (user-level) or `./.claude/agents/$1.md` (project-level) + - Write YAML frontmatter with metadata + - Craft detailed system prompt with role, responsibilities, and workflow + - Include deliverable templates if applicable + +5. **Verify and Test**: + - Check YAML syntax validity + - Verify description includes clear activation triggers + - Confirm tools list is appropriate + - Test invocation with example scenario + +## Storage Locations + +**User-Level**: `~/.claude/agents/subagent-name.md` +- Available across all projects +- For personal workflow automation + +**Project-Level**: `./.claude/agents/subagent-name.md` +- Shared with team via git +- For project-specific expertise +- Higher priority than user-level (overrides on name conflict) + +**Default**: User-level unless project context detected or user specifies + +## Subagent File Structure + +```markdown +--- +name: subagent-identifier +description: Clear description of role AND when to invoke. Include specific keywords and scenarios for automatic activation. +tools: Read, Write, Bash, Grep, Glob # Optional: comma-separated list +model: sonnet # Optional: sonnet, opus, haiku, or inherit +--- + +# Role Definition + +You are a [specific role] specializing in [domain/task]. When invoked, you [primary objective]. + +## Core Responsibilities + +1. **[Responsibility 1]**: Detailed description of what you do +2. **[Responsibility 2]**: Another key responsibility +3. **[Responsibility 3]**: Additional responsibilities + +## Workflow + +When activated, follow these steps: + +1. **Initial Analysis**: + - Analyze the current state/context + - Identify key issues or requirements + - Ask clarifying questions if needed + +2. **Main Task Execution**: + - Perform primary task with specific approach + - Use appropriate tools and techniques + - Follow best practices and standards + +3. **Quality Checks**: + - Verify work meets criteria + - Run tests/validations + - Document findings + +4. **Deliverables**: + - Produce specific outputs + - Provide recommendations + - Update relevant documentation + +## Best Practices + +- [Best practice 1] +- [Best practice 2] +- [Common pitfall to avoid] + +## Quality Criteria + +- [Criterion 1]: [Standard/threshold] +- [Criterion 2]: [Standard/threshold] +- [Criterion 3]: [Standard/threshold] + +## Output Format + +[Template or structure for agent's deliverables] + +## Example Scenarios + +**Scenario 1**: [Description] +- Input: [What triggers this] +- Action: [What you do] +- Output: [What you produce] + +**Scenario 2**: [Another scenario] +- Input: [Trigger] +- Action: [Process] +- Output: [Result] +``` + +## YAML Frontmatter Fields + +| Field | Required | Description | Example | +|-------|----------|-------------|---------| +| **name** | Yes | Lowercase identifier with hyphens | `code-reviewer`, `api-tester` | +| **description** | Yes | Role + activation triggers + keywords | See examples below | +| **tools** | No | Comma-separated tool list; inherits all if omitted | `Read, Write, Bash` | +| **model** | No | Model alias or inherit from parent | `sonnet`, `opus`, `haiku`, `inherit` | + +## Description Best Practices + +**Poor**: "Helps review code" +**Good**: "Expert code review specialist. Reviews code for quality, security, and maintainability. Use immediately after writing or modifying code, before commits, or when refactoring." + +**Poor**: "API testing tool" +**Good**: "API testing specialist. Validates REST endpoints, response schemas, error handling, and performance. Use when testing APIs, debugging HTTP requests, or validating backend services." + +**Poor**: "Requirements analyst" +**Good**: "Requirements analyst and project scoping expert. Elicits comprehensive requirements, creates user stories with acceptance criteria, and generates project briefs. Use when starting new projects, analyzing requirements, or creating specifications." + +## Interactive Questions + +When in interactive mode, ask: + +1. **Role Question**: + - Header: "Agent Role" + - Question: "What specialized role should this subagent fulfill?" + - Options: + - "Code quality expert" - Review, refactor, and improve code + - "Testing specialist" - Write and run tests, validate functionality + - "Architecture advisor" - Design systems, plan structure + - "Domain expert" - Provide specialized domain knowledge + +2. **Activation Question**: + - Header: "Activation" + - Question: "When should Claude automatically invoke this subagent?" + - Options: + - "After code changes" - Proactively review new/modified code + - "Specific keywords" - Trigger on certain terms (requirements, test, etc.) + - "File patterns" - Activate for specific file types/projects + - "Explicit request only" - Only when user directly asks + +3. **Tools Question** (multiSelect: true): + - Header: "Tool Access" + - Question: "Which tools should this subagent have access to?" + - Options: + - "File operations" - Read, Write, Edit, Glob, Grep + - "Shell commands" - Bash execution + - "Web access" - WebFetch, WebSearch + - "All tools (no restrictions)" - Inherits all available tools + +4. **Model Question**: + - Header: "Model" + - Question: "Which AI model should power this subagent?" + - Options: + - "Sonnet (recommended)" - Balanced performance and speed + - "Opus (advanced)" - Most capable, slower, expensive + - "Haiku (fast)" - Quick responses, lighter tasks + - "Inherit from parent" - Use same model as main conversation + +5. **Scope Question**: + - Header: "Scope" + - Question: "Where should this subagent be available?" + - Options: + - "User-level (all projects)" - Save to ~/.claude/agents/ + - "Project-level (this project)" - Save to ./.claude/agents/ + - "Let me decide later" - Recommend based on context + - "Both locations" - Create in both with option to choose + +## Workflow Extraction Logic + +When extracting from recent conversation: + +1. **Identify Domain Patterns**: + - Analyze file types worked with (*.py, *.go, *.ts, etc.) + - Track command patterns (pytest, npm test, git, curl, etc.) + - Detect frameworks/libraries mentioned + - Identify problem domains (testing, debugging, deployment, etc.) + +2. **Extract Tool Usage**: + - Count tool invocations (Read: 15, Bash: 8, Write: 5, etc.) + - Identify essential vs. optional tools + - Note tool sequences (Read → Edit → Bash pattern) + - Determine if web access needed + +3. **Detect Workflow Steps**: + - Find repeated action sequences + - Identify decision points and conditionals + - Extract verification/validation patterns + - Note output/deliverable formats + +4. **Generate System Prompt**: + - Define clear role based on domain + - Structure responsibilities from patterns + - Create step-by-step workflow + - Add quality criteria and best practices + - Include example scenarios from actual history + +5. **Set Activation Triggers**: + - Extract keywords from user messages + - Identify file patterns from glob/grep usage + - Note explicit requests ("test this", "review code") + - Generate description with trigger keywords + +## Subagent Categories & Examples + +### Code Quality & Review +- **code-reviewer**: Reviews for quality, security, maintainability +- **refactoring-expert**: Improves code structure and design +- **security-auditor**: Identifies vulnerabilities and security issues + +### Testing & QA +- **test-writer**: Creates comprehensive test suites +- **test-runner**: Executes tests, diagnoses failures +- **qa-validator**: Validates functionality against requirements + +### Architecture & Design +- **backend-architect**: Designs server-side systems +- **frontend-architect**: Plans client application structure +- **database-designer**: Models data structures and schemas + +### Development Specialists +- **api-developer**: Builds and documents REST/GraphQL APIs +- **ui-implementer**: Creates user interfaces +- **integration-specialist**: Connects external services + +### Analysis & Planning +- **spec-analyst**: Elicits requirements, creates user stories +- **spec-architect**: Designs system structure and interfaces +- **spec-planner**: Breaks work into granular tasks + +### DevOps & Operations +- **deployment-specialist**: Handles releases and deployments +- **monitoring-expert**: Sets up observability and alerts +- **infrastructure-engineer**: Manages cloud resources + +### Domain Experts +- **performance-optimizer**: Improves speed and efficiency +- **accessibility-expert**: Ensures WCAG compliance +- **localization-specialist**: Handles i18n/l10n + +## Multi-Agent Coordination + +Subagents can work together in workflows: + +```bash +# Sequential workflow +"Use spec-analyst to analyze requirements, then spec-architect to design the system" + +# Parallel tasks +"Have code-reviewer check quality while test-runner validates functionality" + +# Handoff pattern +"spec-planner should create tasks, then spec-developer implements them" +``` + +## Advanced Patterns + +### Hub-and-Spoke Coordination +Main agent coordinates multiple specialized subagents: +- Main agent receives user request +- Delegates to appropriate specialists +- Collects and synthesizes results + +### Pipeline Workflow +Sequential phases with quality gates: +1. **Planning**: spec-analyst → spec-architect → spec-planner +2. **Development**: spec-developer → test-writer +3. **Validation**: code-reviewer → qa-validator + +### Specialist On-Demand +Invoke domain experts as needed: +- Security audit: security-auditor +- Performance issue: performance-optimizer +- Accessibility review: accessibility-expert + +## Output Format + +After creation, provide: + +``` +✅ Subagent created successfully: [name] + Location: ~/.claude/agents/[name].md (or project-level) + Role: [Role description] + Model: [sonnet/opus/haiku/inherit] + Tools: [tool list or "all tools"] + +📋 Subagent Details: + - Activates on: [keywords, patterns, or scenarios] + - Primary responsibilities: [list] + - Key capabilities: [list] + +🔍 How to Use: + Automatic: Claude will invoke when context matches + Explicit: "Use the [name] subagent to [task]" + +🧪 Test Command: + Try: "Use the [name] subagent to [example scenario]" + +📝 Next Steps: + 1. Test the subagent with a relevant task + 2. Refine system prompt based on results + 3. Add to project agents if team-relevant + 4. Document use cases for team members +``` + +## Validation Checks + +Before finalizing: + +1. **YAML Syntax**: + - Valid frontmatter delimiters (---) + - Proper field names (name, description, tools, model) + - Correct tool list format (comma-separated) + - Valid model value (sonnet/opus/haiku/inherit) + +2. **Description Quality**: + - Includes role definition + - Contains activation triggers + - Has specific keywords + - Describes when to use + +3. **System Prompt**: + - Clear role definition + - Structured responsibilities + - Step-by-step workflow + - Quality criteria + - Example scenarios + +4. **Tool Restrictions**: + - Appropriate for task + - Not too restrictive + - Not unnecessarily permissive + - Consider security implications + +## Notes + +- **Context Isolation**: Each subagent has its own context window, preventing main conversation pollution +- **Automatic Invocation**: Claude Code proactively invokes subagents based on description and context +- **Explicit Invocation**: Users can request specific subagents: "Use the [name] subagent to..." +- **Priority**: Project-level subagents override user-level when names conflict +- **Tool Inheritance**: Omit `tools` field to inherit all available tools +- **Model Inheritance**: Use `model: inherit` to match parent conversation's model +- **Version Control**: Project subagents can be committed to git for team sharing +- **No Restart Needed**: Subagents are loaded dynamically + +## Examples + +```bash +# Interactive mode - guided creation with questions +/claude:create-subagent + +# Auto mode - extract from recent code review work +/claude:create-subagent code-reviewer + +# Create API testing specialist +/claude:create-subagent api-tester + +# Create requirements analyst +/claude:create-subagent spec-analyst + +# Create performance optimizer +/claude:create-subagent performance-optimizer +``` + +## Debugging Subagents + +If Claude doesn't invoke your subagent: + +1. **Check file location**: + ```bash + ls -la ~/.claude/agents/[name].md + ls -la ./.claude/agents/[name].md + ``` + +2. **Verify YAML syntax**: + ```bash + head -10 ~/.claude/agents/[name].md + ``` + +3. **Test description clarity**: Make it more specific with trigger keywords + +4. **Explicit invocation test**: "Use the [name] subagent to [task]" + +5. **Check tool restrictions**: Ensure required tools aren't blocked + +6. **Review logs**: Run `claude --debug` for error messages + +## Related Commands + +- `/agents` - Built-in interactive agent manager +- `/claude:create-skill` - Create a skill (model-invoked instructions) +- `/claude:create-command` - Create a slash command (user-invoked) + +## Skill vs. Subagent vs. Command + +| Feature | Skill | Subagent | Slash Command | +|---------|-------|----------|---------------| +| **Invocation** | Model-invoked | Model-invoked | User-invoked | +| **Context** | Main conversation | Isolated context | Main conversation | +| **Use Case** | Domain expertise | Complex workflows | Quick automation | +| **Location** | `~/.claude/skills/` | `~/.claude/agents/` | `~/.claude/commands/` | +| **Format** | Folder with SKILL.md | Single .md file | Single .md file | +| **Best For** | Adding capabilities | Task specialization | User shortcuts | + +Choose subagents when: +- Task requires isolated context (large operations) +- Multiple specialized roles needed (multi-agent coordination) +- Proactive invocation desired (automatic delegation) +- Different model needed for sub-task diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..0194b2e --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,53 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:yanmxa/cc-plugins:plugins/claude", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "5ea9db3d08d6b2b39ca6bd481f34236bf39dc06d", + "treeHash": "cb1747f59d2bbf64e24d73cd79b5760920e8e35a2edee8b3002567fc0fe56746", + "generatedAt": "2025-11-28T10:29:09.376636Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "claude", + "description": "Claude Development Plugin", + "version": "1.0.3" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "04f09fc1488543cfa95ca3d5e4e54770dd4b7899eb5427e317aca000572ab201" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "38b7a042ede64f0277f620d0106a480b4317a744257e69deca02a469e3fe2fec" + }, + { + "path": "commands/create-subagent.md", + "sha256": "1dee66b1bb825e7385bfdfecadce2d5d9df6b6bd8c87fa2c7d0d62f3d1a5f173" + }, + { + "path": "commands/create-skill.md", + "sha256": "c0bbf90c0475fa5273cdcd1bf0e71f37b98db784d40b4f59b1b59a05c090f693" + }, + { + "path": "commands/create-command.md", + "sha256": "8956daa8a69d6c439742169a28d96d0d0109128aaf0bf218d80b117d92aaf0e4" + } + ], + "dirSha256": "cb1747f59d2bbf64e24d73cd79b5760920e8e35a2edee8b3002567fc0fe56746" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file