Script Overview
Scripts are stored in.specify/scripts/ with parallel implementations:
- Bash scripts:
.specify/scripts/bash/(Linux, macOS, WSL) - PowerShell scripts:
.specify/scripts/powershell/(Windows, cross-platform)
Core Scripts
create-new-feature
Purpose: Create new feature branch and specification structure Location:- Bash:
.specify/scripts/bash/create-new-feature.sh - PowerShell:
.specify/scripts/powershell/create-new-feature.ps1
- Determines next available feature number
- Generates branch name from description
- Creates Git branch (if Git available)
- Creates feature directory in
specs/ - Copies spec template to feature directory
- Sets
SPECIFY_FEATUREenvironment variable
Branch Naming Logic
Branch Naming Logic
The script intelligently generates branch names:
- Filters stop words: Removes common words (“the”, “a”, “to”, etc.)
- Keeps meaningful words: Words 3+ characters or uppercase acronyms
- Limits length: Uses first 3-4 meaningful words
- Enforces GitHub limit: Truncates to 244 bytes if needed
| Input | Generated Branch |
|---|---|
| ”Add user authentication system” | 001-user-authentication-system |
| ”I want to implement OAuth2” | 001-implement-oauth2 |
| ”Build a REST API for the app” | 001-build-rest-api |
| ”Create UI components” | 001-create-ui-components |
Output Example
Output Example
setup-plan
Purpose: Initialize implementation plan from template Location:- Bash:
.specify/scripts/bash/setup-plan.sh - PowerShell:
.specify/scripts/powershell/setup-plan.ps1
- Validates current feature branch
- Ensures feature directory exists
- Copies plan template to feature directory
- Returns paths to spec and plan files
Output Example
Output Example
check-prerequisites
Purpose: Validate prerequisites for plan/task/implementation phases Location:- Bash:
.specify/scripts/bash/check-prerequisites.sh - PowerShell:
.specify/scripts/powershell/check-prerequisites.ps1
- Validates feature branch exists
- Checks required files (plan.md, tasks.md)
- Identifies available optional documents
- Returns feature directory and document list
--json/-Json: Output in JSON format--require-tasks/-RequireTasks: Fail if tasks.md missing--include-tasks/-IncludeTasks: Include tasks.md in available docs--paths-only/-PathsOnly: Skip validation, return paths only
Output Example
Output Example
update-agent-context
Purpose: Update AI agent context files with latest feature information Location:- Bash:
.specify/scripts/bash/update-agent-context.sh - PowerShell:
.specify/scripts/powershell/update-agent-context.ps1
- Detects agent context files (
.claude/CLAUDE.md,.opencode/README.md, etc.) - Updates feature information section
- Adds/updates paths to current spec, plan, tasks
- Preserves other content in agent files
- Claude Code (
.claude/CLAUDE.md) - Gemini CLI (
.gemini/GEMINI.md) - GitHub Copilot (
.github/copilot-instructions.md) - Cursor (
.cursorrules) - opencode (
.opencode/README.md) - Windsurf (
.windsurfrules) - And more…
common
Purpose: Shared utility functions used by other scripts Location:- Bash:
.specify/scripts/bash/common.sh - PowerShell:
.specify/scripts/powershell/common.ps1
get_feature_paths()/Get-FeaturePathsEnv: Get all feature-related pathscheck_feature_branch()/Test-FeatureBranch: Validate feature branchfind_repo_root()/Find-RepositoryRoot: Locate repository root- File/directory checking utilities
Common Functions
Common Functions
Bash:PowerShell:
Script Integration
Scripts are automatically called by slash commands:| Command | Script Used | Purpose |
|---|---|---|
/speckit.specify | create-new-feature | Create feature structure |
/speckit.plan | setup-plan | Initialize plan file |
/speckit.tasks | check-prerequisites | Validate plan exists |
/speckit.implement | check-prerequisites | Validate tasks exist |
Environment Variables
SPECIFY_FEATURE
Override feature detection for non-Git repositories:Feature Detection
Scripts use this hierarchy to detect the current feature:- Git branch (if Git available): Uses current branch name
- SPECIFY_FEATURE env var: Falls back to environment variable
- Directory scan: Looks for newest feature in
specs/directory
Detection Examples
Detection Examples
Scenario 1: Git repositoryScenario 2: No Git (manual override)Scenario 3: No Git, no env var
Git vs Non-Git Workflows
Git Workflow
Non-Git Workflow
Script Error Handling
All scripts follow consistent error handling:- Exit code 0: Success
- Exit code 1: Error (with descriptive message to stderr)
- Validation failures: Clear error messages guide next steps
Error Examples
Error Examples
Platform Compatibility
Bash Scripts
Compatible with:- Linux (all distributions)
- macOS
- Windows Subsystem for Linux (WSL)
- Git Bash (limited)
- Bash 4.0+
- Standard Unix utilities (grep, sed, awk)
PowerShell Scripts
Compatible with:- Windows PowerShell 5.1+
- PowerShell Core 7.0+ (cross-platform)
- macOS (with PowerShell Core)
- Linux (with PowerShell Core)
- PowerShell 5.1+ or PowerShell Core 7.0+
Debugging Scripts
Enable Debug Output
Common Issues
Script not executable (Bash)
Script not executable (Bash)
Execution policy (PowerShell)
Execution policy (PowerShell)
Git not found
Git not found
Best Practices
Version Control
Do commit:- All scripts in
.specify/scripts/ - Script modifications and customizations
- Common utility functions
- Generated output files
- Temporary debug files
- Platform-specific binaries
Script Modifications
When customizing scripts:- Copy first: Create a custom version
- Document changes: Add comments explaining modifications
- Test both platforms: If modifying both Bash and PowerShell
- Preserve compatibility: Maintain consistent output format
Error Messages
Good error messages:- Explain what went wrong
- Suggest next steps
- Reference relevant commands