Feature Request: Command Pre-execution Dependencies (pre_commands)
Summary
Allow commands to declare a list of commands/skills that are automatically invoked before the command executes.
Problem
Currently, when a command requires certain skills or setup to be invoked first, there's no declarative way to specify this. Users must either:
- Remember to invoke prerequisites manually
- Instruct the model as part of the command to execute commands / invoke skills (but this is unreliable)
Sub-agents already support skills: in YAML frontmatter for auto-loading skills, but commands have no equivalent mechanism.
Proposed Solution: Pre-commands
Add a pre_commands: field to command YAML that executes a list of commands/skills before the main command:
pre_commands:
- /issue-script-access
- /setup-environment
instructions: |
...
Why Pre-commands Over Direct Skill Dependencies
A skills: field (matching sub-agent syntax) would only support skills. The pre_commands: approach is more general:
| Approach | Can invoke | Flexibility |
|---|---|---|
skills: |
Skills only | Limited |
pre_commands: |
Any command or skill | General-purpose |
Pre-commands enables:
- Skill invocation (
/my-skill) - Setup commands (
/setup-env) - Chained workflows (
/validate-config) - Future extensibility
Use Cases
- Gated operations: Commands that require disclosure/agreement skills before execution
- Environment setup: Commands that need specific context loaded first
- Workflow chaining: Multi-step workflows where order matters
- Reducing friction: Eliminate manual prerequisite invocation for predictable workflows
Current Workarounds
- Instructions to the LLM within the command to invoke/execute skills/commands (unreliable)
- Blocking hooks that instruct the LLM to execute commands / invoke skills (multiple tool calls)
Prior Art
- Sub-agents support
skills:in frontmatter for auto-loading (proves the pattern works) - Build systems (Make, Bazel) use dependency declarations
- CI/CD pipelines use
needs:/depends_on:patterns
Design Questions
-
Failure handling: Should failures in pre-commands abort the main command?
- Recommendation: Yes, fail fast with clear error message
-
Circular dependencies: Should there be detection/prevention?
- Recommendation: Yes, detect cycles and error with dependency chain shown
-
Depth limit: Should nested pre-commands be allowed?
- Recommendation: Allow 1-2 levels deep, prevent infinite chains
Example Usage
# commands/deploy.md
pre_commands:
- /validate-config
- /build-check
- /deployment-access
instructions: |
Deploy the application to the specified environment...
When user runs /deploy, the system would:
- Invoke
/validate-config - Invoke
/build-check - Invoke
/deployment-access - Execute the main deploy command instructions