| name | building-commands |
| description | Use when designing command workflows or refactoring existing commands โ applies prompting best practices to ensure agents execute intended logic instead of skipping steps or rationalizing. Use this skill whenever creating new commands, reviewing why a command skipped steps or executed out of order, fixing agent compliance issues, converting Phase-based commands to STEP-based, or when /add-framework--build or /add.build needs to generate a command. Also use when the user mentions "o agente pulou", "agent skipped", "command nรฃo funciona", or asks to improve prompt quality of any .md command file. |
Building Commands
Overview
Commands fail not from unclear logic but from unclear PRESSURE POINTS. Agents skip steps when gates are implicit, execute wrong order when sequence isn't mandatory, and rationalize when checklists are vague timelines instead of checkboxes.
Core principles:
- Imperative > Informative โ Commands are ORDERS, not documentation
- Tool-specific prohibitions โ "DO NOT USE Grep" instead of "STOP"
- Gates block โ Execution path impossible to get wrong
- Checklists verify โ Checkboxes, not timelines
When to Use
Symptoms you need this skill:
- Commands have optional "recommendations" agents skip
- Investigations jump to code before reading docs
- Agents skip branch creation / environment setup steps
- Build/test failures reveal missing validation points
- Post-command status doesn't match what was supposed to happen
Apply when designing/refactoring commands: hotfix, dev, done, feature, plan, etc.
NOT for: Single-line commands, emergency fixes (use quick judgment)
Command Structure
The high-level flow every command follows: load context โ gate check โ investigate โ execute โ complete. Prohibitions sit at the top so the agent processes them before any action.
1. LANG header (MANDATORY)
2. โ Blocking section โ prohibitions BEFORE instructions
3. STEP 1: Load context
4. STEP 2: Validate/discover (gate check)
5. STEP 3: Investigate (docs โ code)
6. STEP N: Execute
7. STEP N+1: Complete (inform user)
8. Rules โ ALWAYS/NEVER markdown
Template
# Command Name
> **LANG:** Respond in user's native language (detect from input). Tech terms always in English.
[1-line description]
---
## โโโ MANDATORY SEQUENTIAL EXECUTION โโโ
**STEPS IN ORDER:**
STEP 1: [action] โ [constraint]
STEP 2: [action] โ [constraint]
**โ ABSOLUTE PROHIBITIONS:**
IF [condition]:
โ DO NOT USE: [specific tool]
โ
DO: [correct action]
---
## STEP 1: ...
---
## Rules
ALWAYS:
- [verb] ...
NEVER:
- [verb] ...
Language Rule (MANDATORY)
ALL commands MUST be written 100% in English. Commands are consumed by multiple providers and contributors across languages โ English is the common denominator. User interaction language is handled by the LANG header.
MANDATORY first line after title:
> **LANG:** Respond in user's native language (detect from input). Tech terms always in English.
This ensures:
- Command logic, headers, rules, gates โ English
- Agent responses to user โ user's detected language
- Git commits, branches, code โ English
DO NOT create "detect language" blocks. The LANG header is sufficient. Modern models detect language automatically from user input. Blocks like "FIRST ACTION: DETECT RESPONSE LANGUAGE โ 1. Read user's message โ 2. Set RESPONSE_LANG..." waste tokens and add zero behavioral value.
Imperative Language (FUNDAMENTAL)
Commands are ORDERS, not documentation. Agents treat informative text as optional context. Imperative text is processed as mandatory instruction.
โ "It's recommended to create the branch before editing code"
โ
"CREATE the branch. DO NOT edit code on main."
โ Phase 1: Quick Discovery
โ
STEP 1: Run Context Mapper (FIRST COMMAND)
โ "The suggested order is: docs โ code โ implementation"
โ
"MANDATORY ORDER: 1) READ docs 2) INVESTIGATE code 3) IMPLEMENT"
Use STEP N: for sequential mandatory actions, N.1/N.2 for sub-actions. Add imperative context: (FIRST COMMAND), (MANDATORY if main), (BEFORE code).
Gate Implementation
NOT: "Recommended: Check X"
YES: "โ GATE: If X not true โ STOP, do Y first"
Agents respect explicit blockers more than recommendations. The reason generic gates fail is that saying "STOP" doesn't prevent the agent from using Grep/Read โ you need to prohibit specific tools.
โ WEAK (agent ignores):
โ GATE: Branch must be fix/F*
If main โ create branch first
โ
STRONG (agent obeys):
IF BRANCH = main:
โ DO NOT USE: Grep on code files
โ DO NOT USE: Read on code files
โ DO NOT: Code investigation or implementation
โ
DO: Create branch IMMEDIATELY
Why it works: "STOP" is vague. "DO NOT USE Grep" is specific and verifiable.
Condition Block Format
Prohibitions must be tied to specific conditions:
IF [condition]:
โ DO NOT USE: [specific tool]
โ DO NOT: [specific action]
โ
DO: [correct action]
Top-of-File Placement
Prohibitions must come BEFORE instructions. If they're in the middle or end, the agent has already started executing wrong. Agent reads top-down โ prohibitions at the top are processed before any action.
Checklists, Not Timelines
Checkboxes are verifiable โ either done or not. Timelines are estimates the agent ignores because there's no verification mechanism.
โ BAD:
Phase 2: Rapid Investigation (5-10 minutes)
- Analyze flow
- Find root cause
โ
GOOD:
### PRE-INVESTIGATION
- [ ] Script executed
- [ ] RECENT_CHANGELOGS analyzed
- [ ] Feature docs read
### DURING
- [ ] Root cause identified
- [ ] Confirmed with user
Investigation Order (MANDATORY)
1. Parse script output โ identify related features
2. READ docs (changelog, about.md) โ understand WHAT changed + WHY
3. NOW search code โ understand HOW (with context from docs)
Most bugs relate to recent changes. Script output points directly to the relevant context. Jumping to code without reading docs means investigating blind.
No ## Spec Section (PROHIBITED)
DO NOT add a ## Spec section to commands or skills. Output paths, modes, schemas, write boundaries, and similar metadata belong in the frontmatter description and the STEP body โ not in a separate JSON metadata block at the top of the file.
Why: nothing programmatically consumes ## Spec (build.js, CLI, runtime all ignore it). It duplicates information already in the description and STEPs, which creates drift risk. Open-source contributors must mentally pretty-print minified JSON to read it.
โ DO NOT โ top-of-file metadata block:
## Spec
```json
{"outputs":{"plan":"docs/features/${FEATURE_ID}/plan.md"},"schema":"feature-plan"}
โ
DO โ state output and schema in prose where they're used:
STEP 9: Write plan.md
Write to docs/features/${FEATURE_ID}/plan.md per the feature-plan schema.
If a JSON example genuinely helps (e.g., showing the shape of an output document), put it under a heading that names what it is โ `## Output Format`, `## Output Template` โ inside the section that explains the output. Not as a metadata block at the top.
---
## Bash Blocks: Intent Over Script
**DO NOT prescribe bash commands for operations the LLM already knows.** `git branch --show-current`, `cat file | grep`, `git checkout && git merge` โ these waste tokens stating the obvious.
**Use explicit bash ONLY when:**
- A past error proved the LLM gets it wrong without guidance (e.g., `git fetch --tags` before listing tags)
- The exact command matters and is non-obvious (e.g., specific flags, pipe chains)
- The command has side effects that must be precise (e.g., `sed` with exact regex)
โ BAD (obvious):
Execute: git branch --show-current
If not main, display error and stop.
โ
GOOD (intent):
Verify current branch is main. If not โ show current branch, instruct to switch, STOP.
โ
GOOD (non-obvious, learned from error):
Execute:
git fetch --tags
git tag --sort=-v:refname
CRITICAL: Without fetch, remote tags are invisible locally.
---
## Display Templates: Let the LLM Generate
**DO NOT prescribe fixed message templates.** The LLM generates better contextual messages than hardcoded templates. Templates waste tokens for worse output.
**Exception:** Output format templates that define downstream structure (changelog format, report format) ARE useful โ they define what the output looks like, not what the error message says.
โ BAD (fixed error message):
If NOT_FOUND, display:
"GitHub CLI (gh) not found. Install: ..."
โ
GOOD (intent):
If gh not found โ show install instructions for user's platform and STOP.
โ
GOOD (output format template):
Format changelog (omit empty sections):
Commands
- Added: [list]
- Modified: [list]
---
## Rules Section Format
Commands end with a `## Rules` section using ALWAYS/NEVER markdown. This format uses ~30% fewer tokens than JSON for flat lists, has higher compliance with native imperative language, and aligns with condition blocks already used in commands.
```markdown
## Rules
ALWAYS:
- Complete STEP 3 inspection before ANY layout proposal
- Load relevant skill BEFORE implementing
- Log iteration BEFORE informing user
NEVER:
- Commit or stage any code
- Skip discovery phase
- Proceed without response to [STOP]
Conventions:
- Each item starts with a verb in infinitive form
- No numbering (permanent rules, not sequence)
- Maximum ~15 words per item
- Rules MUST contain ONLY information NOT derivable from STEP order or condition blocks
Test each rule: "If I remove this rule, would the LLM behave differently given the STEPs and prohibitions?" If NO โ redundant, remove it.
โ REDUNDANT (already in STEP order):
ALWAYS: Merge main into production before creating tag โ STEP 6 before STEP 8
โ
NOT REDUNDANT (business knowledge outside STEPs):
NEVER: Run node scripts/build.js โ pipeline's job
Log Iteration (Mandatory Completion Step)
Every command that modifies code MUST log iteration before user notification. Iteration tracking enables pattern discovery across runs โ without it, the same mistakes repeat because there's no history to learn from.
bash .fnd/scripts/log-iteration.sh "type" "slug" "what" "files"
Types: fix, enhance, refactor, add, remove, config
Agent Dispatch
Commands that orchestrate multiple subagents MUST use intent-based dispatch for portability across agent engines. Read references/agent-dispatch.md for the full pattern (capability levels, complexity hints, dispatch/wait blocks).
Refactoring Workflow
When refactoring an existing command using this skill:
STEP 1: Read โ Read the target command completely.
STEP 2: Audit โ Run the Validation Checklist below. List every violation found.
STEP 3: Classify โ For each section of the command, assign one action:
| Action | When |
|---|
| KEEP | Business logic, domain knowledge, learned-from-error rules |
| REMOVE | Spec JSON duplicating STEPs, detect-language blocks, obvious bash, fixed display templates, redundant rules |
| SIMPLIFY | Verbose STEPs โ intent-only (remove bash/templates, keep what the step must achieve) |
| REFORMAT | Rules JSON โ ALWAYS/NEVER markdown, PT-BR โ English, Phase โ STEP |
STEP 4: Rewrite โ Rewrite the command preserving all business logic. Verify no domain knowledge was lost by comparing KEEP items against the new version.
Validation Checklist
Before deploying command:
Structure
Gates & Prohibitions
Order & Verification
Resource Path References
Rules Section
Completion
Agent Dispatch (if command uses subagents)
Common Mistakes
| Mistake | Fix |
|---|
| Informative language ("it's recommended") | Imperative ("EXECUTE", "DO NOT") |
| Generic gate ("STOP, create branch") | Tool prohibition: "DO NOT USE Grep if BRANCH=main" |
| Prohibitions in middle of file | Move to TOP-OF-FILE before instructions |
| Using "Phase" (documentary) | Use "STEP" (imperative) |
| Command written in PT-BR or mixed | Command 100% in English + LANG header |
## Spec section at top of file | Remove โ prohibited (see "No ## Spec Section") |
| Bash blocks for obvious operations | Use intent: "Verify branch is main. If not โ STOP" |
| Fixed display/error message templates | Let the LLM generate contextual messages |
| Rules that restate STEP order | Remove โ STEP sequence already enforces this |
| "DETECT LANGUAGE" blocks after LANG header | Remove โ LANG header is sufficient |
{"do":[...],"dont":[...]} for rules | Use ALWAYS/NEVER markdown |