.forge/commands directory and can be invoked instantly from the Forge CLI.
Overview
Custom commands let you:- Automate workflows - Turn multi-step processes into single commands
- Standardize practices - Share team conventions and procedures
- Embed expertise - Capture domain knowledge in executable form
- Accelerate development - Reduce repetitive prompting
Example Use Case
Create a
fixme command that automatically finds all FIXME comments in your codebase and attempts to resolve them, or a check command that runs your full test and lint suite.Command Structure
Commands are Markdown files with YAML frontmatter:File Location
Commands must be stored in:Creating Commands
- Basic Command
- Multi-Step Workflow
Create a simple command for code review:
Special Command Tags
Forge supports special XML-style tags for automated workflows:Available Tags
- Extract and execute the command automatically
- Capture the output for the AI to process
- Continue the workflow based on results
Built-in Command Examples
Forge includes example commands you can reference:FIXME Command
Check Command
Using Commands
- CLI Flag
- Interactive Mode
- Shell Integration
Execute a command using the
-c or --command flag:Command Best Practices
Writing Effective Commands
Be Specific
Provide clear, actionable instructions. Avoid ambiguous language.Good: “Run eslint with —fix flag and report any remaining errors”Bad: “Check the code”
Naming Conventions
- Use kebab-case for file names:
my-command.md - Keep names short and descriptive:
review,deploy,check - Avoid special characters except hyphens
- Command name in frontmatter should match filename (without
.md)
Advanced Patterns
Conditional Logic
Parameterized Commands
Integration with Other Tools
Team Workflows
Share commands with your team:- Commit to repository - Include
.forge/commands/in version control - Document in README - List available commands and their purposes
- Standardize practices - Create commands for onboarding, reviews, releases
- Iterate together - Improve commands based on team feedback
Example Team Commands
onboard- Guide new developers through setupsecurity-check- Run security audit toolsperformance-profile- Generate performance reportsupdate-deps- Update dependencies safelygenerate-docs- Build and verify documentation
Troubleshooting
Command not found
Command not found
- Verify file is in
.forge/commands/directory - Check filename ends with
.md - Ensure YAML frontmatter is valid
- Restart Forge to reload command registry
Command executes but doesn't work as expected
Command executes but doesn't work as expected
- Review command instructions for clarity
- Test special tags (
<lint>,<test>) in isolation - Check for conflicting instructions
- Add more specific context and examples
Special tags not executing
Special tags not executing
Command Library
Explore the community command library at forgecode.dev/commands for:- Pre-built commands for common tasks
- Language-specific workflows
- Framework integrations
- Best practice examples
Related Features
- Shell Integration - Execute commands from your shell
- Git Operations - Commands for git workflows
- Multi-Agent Workflows - Orchestrate multiple agents with commands