budget
The budget command monitors Vercel and Railway deployment quotas within a 24-hour rolling window by querying GitHub Actions workflows and Railway CLI. Use this command to track remaining deployment capacity, predict quota reset times, and receive deployment strategy recommendations before hitting rate limits. It counts marketing and app staging deployments against Vercel's 100-per-day limit and alerts when remaining quota drops below warning thresholds.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/marcusgoll/Spec-Flow/HEAD/.claude/commands/deployment/budget.md -o ~/.claude/commands/budget.mdbudget.md
<context>
GitHub CLI authenticated: !`gh auth status >/dev/null 2>&1 && echo "✅ Yes" || echo "❌ No - run gh auth login"`
24h timestamp (GNU): !`date --version 2>/dev/null | grep -q GNU && date -d '24 hours ago' -Iseconds || echo "N/A"`
24h timestamp (BSD): !`date --version 2>/dev/null | grep -q GNU || date -u -v-24H -Iseconds 2>/dev/null || echo "N/A"`
Marketing deployments (24h): !`SINCE=$(date --version 2>/dev/null | grep -q GNU && date -d '24 hours ago' -Iseconds || date -u -v-24H -Iseconds); gh run list --workflow=deploy-staging.yml --created="$SINCE" --json conclusion --jq 'length' 2>/dev/null || echo "0"`
App deployments (24h): !`SINCE=$(date --version 2>/dev/null | grep -q GNU && date -d '24 hours ago' -Iseconds || date -u -v-24H -Iseconds); gh run list --workflow=deploy-app-staging.yml --created="$SINCE" --json conclusion --jq 'length' 2>/dev/null || echo "0"`
Railway CLI installed: !`command -v railway >/dev/null 2>&1 && echo "✅ Yes" || echo "❌ No"`
Railway usage: !`railway usage 2>/dev/null || echo "Railway CLI not available"`
Oldest deployment timestamp: !`SINCE=$(date --version 2>/dev/null | grep -q GNU && date -d '24 hours ago' -Iseconds || date -u -v-24H -Iseconds); gh run list --workflow=deploy-staging.yml --created="$SINCE" --limit 1 --json createdAt --jq '.[0].createdAt' 2>/dev/null || echo ""`
Recent deployment statuses: !`SINCE=$(date --version 2>/dev/null | grep -q GNU && date -d '24 hours ago' -Iseconds || date -u -v-24H -Iseconds); gh run list --workflow=deploy-staging.yml --created="$SINCE" --limit 10 --json conclusion,createdAt,displayTitle --jq '.[] | "\(.conclusion) - \(.displayTitle) - \(.createdAt)"' 2>/dev/null || echo ""`
</context>
<objective>
Track deployment quota usage and predict remaining capacity to prevent rate limiting during deployments.
**What it does:**
- Counts Vercel deployments in 24h rolling window (Marketing + App)
- Checks Railway compute usage (if CLI available)
- Calculates quota reset time from oldest deployment
- Predicts remaining quota after next deployment
- Provides deployment strategy based on quota status
- Analyzes recent deployment failure rate
**Operating constraints:**
- **Vercel Limit** — 100 deployments per 24 hours (rolling window)
- **Warning Threshold** — Alert when < 20 remaining
- **Critical Threshold** — Block when < 10 remaining
- **Read-Only** — Never modifies quotas or settings
- **Non-Blocking** — Always returns, even on errors
**Dependencies:**
- GitHub CLI installed and authenticated (gh auth login)
- Railway CLI optional (for compute usage tracking)
- Access to deploy-staging.yml and deploy-app-staging.yml workflows
</objective>
<process>
1. **Verify GitHub CLI authentication**:
- Check if gh auth status succeeds
- If not authenticated, display error and exit:
```
❌ GitHub CLI not authenticated
Run: gh auth login
```
2. **Calculate total Vercel deployments**:
- Sum Marketing + App deployments from context
- Calculate remaining: 100 - total_used
- Determine status:
- **normal**: >= 20 remaining (✅)
- **warning**: 10-19 remaining (⚠️)
- **critical**: < 10 remaining (🚨)
3. **Display Vercel quota section**:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Deployment Budget (24h rolling)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Vercel Deployments:
Marketing (staging): {count}
App (staging): {count}
Total used: {total} / 100
Remaining: {remaining}
{status_emoji} {STATUS} - {remaining} deployments {available/remaining/left}
```
4. **Display Railway usage** (if CLI available):
- If Railway CLI installed, show usage output
- If not installed, show installation instructions:
```
⚠️ Railway CLI not installed
Install: npm install -g @railway/cli
```
5. **Calculate quota reset time**:
- Extract oldest deployment timestamp from context
- Calculate reset time (24 hours from oldest)
- Calculate time remaining until reset (hours and minutes)
- Display:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Quota Reset Information
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Oldest deployment: {timestamp}
Quota resets at: {reset_time}
Time to reset: {hours}h {minutes}m
```
6. **Predict next deployment impact**:
- Deployment cost: 2 (Marketing + App for staging)
- Projected remaining: current_remaining - 2
- Display prediction:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Next Deployment Impact
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Next /ship --staging will use:
Marketing: 1 deployment
App: 1 deployment
Total: 2 deployments
Projected remaining: {projected} / 100
```
- Add warning if projected < 0:
```
🚨 WOULD EXCEED QUOTA
Options:
A) Wait for quota reset ({reset_time})
B) Use preview mode (doesn't count toward quota)
C) Skip deployment and create draft PR
```
7. **Provide deployment strategy recommendations**:
- **If critical status**:
```
Current status: CRITICAL ({remaining} remaining)
🛑 DO NOT use staging mode
Recommended actions:
1. Wait for quota reset ({reset_time})
2. OR use preview mode:
- Tests CI without consuming quota
- Doesn't update staging.cfipros.com
- Unlimited usage
Preview mode usage:
/ship --staging
→ Select 'preview' when prompted
```
- **If warning status**:
```
Current status: LOW ({remaining} remaining)
⚠️ Use quota carefully
Best practices:
1. Run /validate-staging before every deployment
2. Use preview mode for CI testing
3. Use staging mode only for actual staging deploys
4. Fix issues locally before pushing
Workflow:
/validate-staging → /ship (preview) → verify → /ship (staging)
```
- **If normal status**:
```
Current status: NORMExecute multiple sprints in parallel based on dependency graph from sprint-plan.md
Build and validate locally for projects without remote deployment (prototypes, experiments, local-only dev)
Execute multi-sprint epic workflow from interactive scoping through deployment with parallel sprint execution and self-improvement
Execute feature development workflow from specification through production deployment with automated quality gates
Analyze workflow state and provide context-aware guidance with visual progress indicators and recommended next steps
Initialize project documentation, preferences, or design tokens
Implement small bug fixes and features (<100 LOC) without full workflow. Use for single-file changes, bug fixes, refactors, and minor enhancements that can be completed in under 30 minutes.
Enter deep craftsman mode - question everything, plan like Da Vinci, craft insanely great solutions, then materialize to roadmap