项目文件夹

文件
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 行
7.1 KiB
JSON

{"content": "---\nname: command-creator\ndescription: This skill should be used when creating a Claude Code slash command. Use when users ask to \"create a command\", \"make a slash command\", \"add a command\", or want to document a workflow as a reusable command. Essential for creating optimized, agent-executable slash commands with proper structure and best practices.\n---\n\n# Command Creator\n\nThis skill guides the creation of Claude Code slash commands - reusable workflows that can be invoked with `/command-name` in Claude Code conversations.\n\n## About Slash Commands\n\nSlash commands are markdown files stored in `.claude/commands/` (project-level) or `~/.claude/commands/` (global/user-level) that get expanded into prompts when invoked. They're ideal for:\n\n- Repetitive workflows (code review, PR submission, CI fixing)\n- Multi-step processes that need consistency\n- Agent delegation patterns\n- Project-specific automation\n\n## When to Use This Skill\n\nInvoke this skill when users:\n\n- Ask to \"create a command\" or \"make a slash command\"\n- Want to automate a repetitive workflow\n- Need to document a consistent process for reuse\n- Say \"I keep doing X, can we make a command for it?\"\n- Want to create project-specific or global commands\n\n## Bundled Resources\n\nThis skill includes reference documentation for detailed guidance:\n\n- **references/patterns.md** - Command patterns (workflow automation, iterative fixing, agent delegation, simple execution)\n- **references/examples.md** - Real command examples with full source (submit-stack, ensure-ci, create-implementation-plan)\n- **references/best-practices.md** - Quality checklist, common pitfalls, writing guidelines, template structure\n\nLoad these references as needed when creating commands to understand patterns, see examples, or ensure quality.\n\n## Command Structure Overview\n\nEvery slash command is a markdown file with:\n\n```markdown\n---\ndescription: Brief description shown in /help (required)\nargument-hint: <placeholder> (optional, if command takes arguments)\n---\n\n# Command Title\n\n[Detailed instructions for the agent to execute autonomously]\n```\n\n## Command Creation Workflow\n\n### Step 1: Determine Location\n\n**Auto-detect the appropriate location:**\n\n1. Check git repository status: `git rev-parse --is-inside-work-tree 2>/dev/null`\n2. Default location:\n - If in git repo → Project-level: `.claude/commands/`\n - If not in git repo → Global: `~/.claude/commands/`\n3. Allow user override:\n - If user explicitly mentions \"global\" or \"user-level\" → Use `~/.claude/commands/`\n - If user explicitly mentions \"project\" or \"project-level\" → Use `.claude/commands/`\n\nReport the chosen location to the user before proceeding.\n\n### Step 2: Show Command Patterns\n\nHelp the user understand different command types. Load **references/patterns.md** to see available patterns:\n\n- **Workflow Automation** - Analyze → Act → Report (e.g., submit-stack)\n- **Iterative Fixing** - Run → Parse → Fix → Repeat (e.g., ensure-ci)\n- **Agent Delegation** - Context → Delegate → Iterate (e.g., create-implementation-plan)\n- **Simple Execution** - Run command with args (e.g., codex-review)\n\nAsk the user: \"Which pattern is closest to what you want to create?\" This helps frame the conversation.\n\n### Step 3: Gather Command Information\n\nAsk the user for key information:\n\n#### A. Command Name and Purpose\n\nAsk:\n\n- \"What should the command be called?\" (for filename)\n- \"What does this command do?\" (for description field)\n\nGuidelines:\n\n- Command names MUST be kebab-case (hyphens, NOT underscores)\n - ✅ CORRECT: `submit-stack`, `ensure-ci`, `create-from-plan`\n - ❌ WRONG: `submit_stack`, `ensure_ci`, `create_from_plan`\n- File names match command names: `my-command.md` → invoked as `/my-command`\n- Description should be concise, action-oriented (appears in `/help` output)\n\n#### B. Arguments\n\nAsk:\n\n- \"Does this command take any arguments?\"\n- \"Are arguments required or optional?\"\n- \"What should arguments represent?\"\n\nIf command takes arguments:\n\n- Add `argument-hint: <placeholder>` to frontmatter\n- Use `<angle-brackets>` for required arguments\n- Use `[square-brackets]` for optional arguments\n\n#### C. Workflow Steps\n\nAsk:\n\n- \"What are the specific steps this command should follow?\"\n- \"What order should they happen in?\"\n- \"What tools or commands should be used?\"\n\nGather details about:\n\n- Initial analysis or checks to perform\n- Main actions to take\n- How to handle results\n- Success criteria\n- Error handling approach\n\n#### D. Tool Restrictions and Guidance\n\nAsk:\n\n- \"Should this command use any specific agents or tools?\"\n- \"Are there any tools or operations it should avoid?\"\n- \"Should it read any specific files for context?\"\n\n### Step 4: Generate Optimized Command\n\nCreate the command file with agent-optimized instructions. Load **references/best-practices.md** for:\n\n- Template structure\n- Best practices for agent execution\n- Writing style guidelines\n- Quality checklist\n\nKey principles:\n\n- Use imperative/infinitive form (verb-first instructions)\n- Be explicit and specific\n- Include expected outcomes\n- Provide concrete examples\n- Define clear error handling\n\n### Step 5: Create the Command File\n\n1. Determine full file path:\n - Project: `.claude/commands/[command-name].md`\n - Global: `~/.claude/commands/[command-name].md`\n\n2. Ensure directory exists:\n\n ```bash\n mkdir -p [directory-path]\n ```\n\n3. Write the command file using the Write tool\n\n4. Confirm with user:\n - Report the file location\n - Summarize what the command does\n - Explain how to use it: `/command-name [arguments]`\n\n### Step 6: Test and Iterate (Optional)\n\nIf the user wants to test:\n\n1. Suggest testing: `You can test this command by running: /command-name [arguments]`\n2. Be ready to iterate based on feedback\n3. Update the file with improvements as needed\n\n## Quick Tips\n\n**For detailed guidance, load the bundled references:**\n\n- Load **references/patterns.md** when designing the command workflow\n- Load **references/examples.md** to see how existing commands are structured\n- Load **references/best-practices.md** before finalizing to ensure quality\n\n**Common patterns to remember:**\n\n- Use Bash tool for `pytest`, `pyright`, `ruff`, `prettier`, `make`, `gt` commands\n- Use Task tool to invoke subagents for specialized tasks\n- Check for specific files first (e.g., `.PLAN.md`) before proceeding\n- Mark todos complete immediately, not in batches\n- Include explicit error handling instructions\n- Define clear success criteria\n\n## Summary\n\nWhen creating a command:\n\n1. **Detect location** (project vs global)\n2. **Show patterns** to frame the conversation\n3. **Gather information** (name, purpose, arguments, steps, tools)\n4. **Generate optimized command** with agent-executable instructions\n5. **Create file** at appropriate location\n6. **Confirm and iterate** as needed\n\nFocus on creating commands that agents can execute autonomously, with clear steps, explicit tool usage, and proper error handling.\n"}