Guide: Creating Cursor Commands¶
Step-by-step guide for creating new Cursor commands for the Tux project.
Quick Start¶
- Choose Category - Select appropriate category directory
- Copy Template - Use
.cursor/templates/command-template.md - Fill Content - Add project-specific workflow
- Validate - Ensure command meets standards
- Test - Verify command works correctly
Detailed Steps¶
Step 1: Choose Category¶
Select the category that best fits your command:
code-quality/- Code quality workflowstesting/- Testing workflowsdatabase/- Database workflowsdiscord/- Discord bot workflowssecurity/- Security workflowsdebugging/- Debugging workflowserror-handling/- Error handling workflowsdocumentation/- Documentation workflowsdevelopment/- Development workflows
Step 2: Create File¶
- Navigate to appropriate category directory
- Create new
.mdfile with kebab-case name - Example:
database/migration.md
Step 3: Write Title¶
Use clear, action-oriented title:
Markdown
# Database Migration
Step 4: Write Overview¶
Brief description of what the command does:
Markdown
## Overview
Create and apply Alembic database migrations for schema changes.
Step 5: Write Steps¶
Numbered steps with sub-steps:
Markdown
## Steps
1. **Create Migration**
- Run `uv run db migrate-dev "description"`
- Review generated migration file
- Verify upgrade and downgrade functions
2. **Review Migration**
- Ensure both functions implemented
- Check for proper constraints
- Validate enum handling
Step 6: Add Error Handling¶
Include troubleshooting:
Markdown
## Error Handling
If migration fails:
- Check migration file syntax
- Verify database connection
- Review error messages
Step 7: Add Checklist¶
Verifiable checklist items:
Markdown
## Checklist
- [ ] Migration file created
- [ ] Both upgrade and downgrade implemented
- [ ] Migration tested
- [ ] Applied to development database
Step 8: Add Cross-References¶
Link to related commands and rules:
Markdown
## See Also
- Related command: `/database-health`
- Related rule: @database/migrations.mdc
Example: Creating a Database Command¶
- Category:
database/ - File:
database/migration.md - Title:
# Database Migration - Overview: Brief description
- Steps: Numbered workflow steps
- Error Handling: Troubleshooting guide
- Checklist: Verifiable items
- See Also: Cross-references
Common Patterns¶
Simple Command¶
Markdown
# Command Title
## Overview
Brief description.
## Steps
1. Step one
2. Step two
## Checklist
- [ ] Item one
- [ ] Item two
Complex Command¶
Markdown
# Command Title
## Overview
Detailed description.
## Steps
1. **Step Title**
- Sub-step
- Detail
2. **Step Title**
- Sub-step
## Error Handling
Troubleshooting steps.
## Checklist
- [ ] Item one
- [ ] Item two
## See Also
- Related command: `/other`
- Related rule: @rule.mdc
Best Practices¶
- Be Action-Oriented - Use verbs in title
- Clear Steps - Numbered, with sub-steps
- Complete Checklist - Verifiable items
- Error Handling - Include troubleshooting
- Cross-Reference - Link to related commands/rules
- Project-Specific - Reference Tux tools and patterns
Templates¶
Complete Command Template¶
Markdown
# Command Title
## Overview
Brief description of command purpose and expected outcome.
## Steps
1. **Step Title**
- Sub-step or detail
- Additional context
2. **Step Title**
- Sub-step or detail
## Error Handling
If operation fails:
- Troubleshooting step 1
- Troubleshooting step 2
## Checklist
- [ ] Item one
- [ ] Item two
- [ ] Item three
## See Also
- Related command: `/other-command`
- Related rule: @rule-name.mdc
Standards¶
Naming¶
- Commands: kebab-case, action-oriented (e.g.,
database-migration.md) - Location:
.cursor/commands/{category}/ - Format:
.mdfiles (plain markdown)
Content Requirements¶
- Project-specific: Tailored to Tux, not generic
- Examples: Include working code examples
- Error handling: Show how to handle failures
- Cross-references: Link to related commands/rules
Quality Standards¶
- Clear, actionable content
- Consistent formatting
- Complete checklists
- Proper error handling
Validation¶
Run validation before committing:
Bash
uv run rules validate
This checks:
- File structure
- Content requirements (steps, checklist)
- Error handling included
- Cross-references complete
Maintenance¶
Updating Commands¶
- Update steps when workflows change
- Keep checklists current
- Update error handling as needed
- Verify all commands still work
Review Process¶
- Review commands during code reviews
- Update when project patterns change
- Remove obsolete commands
- Consolidate duplicate content
See Also¶
- Command Template
- Creating Cursor Rules - Guide for creating rules
- meta/cursor-commands.mdc - Commands specification