Command Architect
Designs automation workflows following the strict Tier structure and YAML/Markdown standards.
1. Context Injection (MANDATORY)
Before writing any command file, you MUST determine the complexity tier and read the relevant standards:
- •Determine Tier:
- •Tier 1 (Utility): Simple, single-step (e.g., "find todos").
- •Tier 2 (Workflow): Linear, multi-step (e.g., "create commit").
- •Tier 3 (Autonomous): Complex, phased, checkpoints (e.g., "fix issue", "release").
- •Load Architecture:
Read("reference/command-architecture.md") - •Load Templates:
Read("templates/tier1.md", "templates/tier2.md" or "templates/tier3.md")(Load ONLY the matching tier).
2. Validation Protocol (The "Syntax-Check" Rule)
Command instructions often fail because they use incorrect CLI flags or outdated tool arguments.
- •Volatile Syntax: If the new command uses CLI tools (e.g.,
gh,aws,kubectl,npm), useWebSearchto verify the exact flags and output formats.- •Query: "gh issue list json output format", "aws s3 sync flags".
- •Timeless Syntax: Rely on
reference/syntax-guide.mdfor internal Claude Code syntax like!command,@file, and$ARGUMENTS.
3. Core Workflow
Phase 1: Definition
- •Name: Determine the filename (kebab-case, e.g.,
fix-issue.md). - •Namespace: Decide if it belongs in a subdirectory (e.g.,
.claude/commands/release/). - •Frontmatter: Define
allowed-toolsstrictly. Only grant what is needed.- •Commands vs Skills: Commands are user-invoked (via
/command-name) and should NOT have aname:field. Skills are model-invoked and MUST have aname:field in.claude/skills/*/SKILL.md.
- •Commands vs Skills: Commands are user-invoked (via
Phase 2: Skill Dependency Mapping (CRITICAL)
Identify required capabilities: Does this command require domain expertise (e.g., DB migrations, UI design)?
- •IF YES: You MUST verify if a relevant skill exists in
.claude/skills/. - •Action: Add an explicit instruction in the command's "Phase 1" to read that skill's
SKILL.md.- •Example: "Load DB Expertise:
Read('.claude/skills/managing-d1-migrations/SKILL.md')"
- •Example: "Load DB Expertise:
Phase 3: Structural Drafting
- •Use the Template: Copy the structure from
templates/. - •State Management (Tier 3 Only): If the command is complex, you MUST generate a "Progress Tracking" section that writes to
.claude/progress/. - •Extended Thinking: Use
think hardorultrathinkkeywords in the command body for complex reasoning steps.
Phase 4: File Creation
- •Create the file in
.claude/commands/.... - •Validate that
descriptionandargument-hintare present in the YAML header. - •CRITICAL: Ensure the frontmatter does NOT contain a
name:field (that's only for skills in.claude/skills/*/SKILL.md).
4. Critical Rules (Enforced)
ALWAYS:
- •Use kebab-case for filenames.
- •Include
model: claude-sonnet-4-5-20250929(or newer) for complex logic. - •Use explicit "STOP" checkpoints in Tier 3 commands.
- •Inject Skills: Explicitly
Read()theSKILL.mdof any domain skill required for the task. Do not rely on the agent "knowing" how to migrate a database; force it to read the manual.
NEVER:
- •Create "Do-Everything" commands (Monoliths). Split them.
- •Forget the YAML frontmatter.
- •Use ambiguous constraints (e.g., "Be careful"). Use explicit constraints (e.g., "Do NOT delete files").
- •Include a
name:field in command frontmatter (commands are user-invoked via filename, not name field). - •Use
---anywhere except YAML frontmatter delimiters. The parser interprets---as document boundaries, breaking commands with heredocs containing---.
5. External Scripts Pattern (Tier 2-3)
For commands with complex bash logic, delegate to external scripts rather than inline bash:
When to use external scripts:
- •Any heredocs
- •Argument parsing (flags, options, positional args)
- •Control flow (if/for/while/case)
- •More than ~5 lines of bash
- •Logic that needs to be testable independently
Pattern:
- •Create script in
.claude/scripts/<command-name>.sh - •Command file calls the script with arguments
- •Script handles all bash complexity
Example structure:
markdown
## Execute \`\`\`bash bash .claude/scripts/my-command.sh $ARGUMENTS \`\`\`
Benefits:
- •Deterministic execution (no Claude interpretation of multi-phase bash)
- •Testable independently (
bash .claude/scripts/x.sh --help) - •Avoids YAML parser conflicts with
---in heredocs - •Cleaner command files focused on workflow, not bash details
See /propose-upstream and /retro as reference implementations.