Add and validate production infrastructure one bundle at a time
Adds and validates production infrastructure bundles for health, security, backup, and deployment.
/plugin marketplace add moshehbenavraham/apex-spec-system/plugin install apex-spec@apex-spec-marketplaceAdd and validate production infrastructure one bundle at a time. Follows the universal 9-step flow shared with /audit and /pipeline.
Industry standard order (availability to automation):
| Priority | Bundle | Contents |
|---|---|---|
| 1 | Health | /health endpoint + platform probes |
| 2 | Security | WAF rules + rate limiting |
| 3 | Backup | DB backup + storage + retention policy |
| 4 | Deploy | CD webhook/trigger from main branch |
| Flag | Default | Description |
|---|---|---|
--dry-run | false | Preview what would happen without changes |
--skip-install | false | Don't create configs or scripts |
--verbose | false | Show full command output |
Check for .spec_system/CONVENTIONS.md
Detect infrastructure from existing files/configs:
wrangler.toml = Cloudflaredocker-compose.yml, coolify.json = Coolify/Dockervercel.json = Vercelfly.toml = Fly.ioCheck for .spec_system/audit/known-issues.md
If --dry-run: Skip to Dry Run Output
Compare Infrastructure table against 4-bundle master list:
Build list of missing bundles in priority order.
If all bundles configured: "All infrastructure configured. Jumping to Step 5 to Validate."
Pick the highest-priority missing bundle from Step 2.
Output: "Selected: [Bundle Name] - not yet configured"
Add configuration for the selected bundle.
Stack-agnostic implementations:
| Bundle | Component | Implementation varies by platform |
|---|---|---|
| Health | Endpoint | FastAPI, Express, Go handler, etc. |
| Health | Probe | Coolify, Kubernetes, ECS, Vercel, etc. |
| Security | WAF | Cloudflare, AWS WAF, Vercel Firewall |
| Security | Rate Limit | slowapi, express-rate-limit, in-platform |
| Backup | Script | pg_dump, mongodump, mysqldump |
| Backup | Storage | R2, S3, GCS, local |
| Backup | Schedule | Cron, GitHub Actions, platform scheduler |
| Deploy | Trigger | Webhook, Git push, platform integration |
Implementation by detected stack:
Health Bundle:
# FastAPI example
@app.get("/health")
async def health():
return {
"status": "healthy",
"database": await check_db(),
"cache": await check_cache(),
"timestamp": datetime.utcnow().isoformat()
}
Security Bundle:
Backup Bundle:
Deploy Bundle:
Verify all configured infrastructure:
curl the /health endpoint, verify 200 + JSONValidation commands by component:
| Component | Validation |
|---|---|
| Health endpoint | curl -f https://domain.com/health |
| Rate limiting | Rapid requests should get 429 |
| Backup | Check storage for file < 24h old |
| Deploy webhook | curl -X POST webhook_url (dry-run if possible) |
For each validation failure:
After 3 failed attempts: Log for manual review.
Filter out items in known-issues.md Skipped Infra section.
Update .spec_system/CONVENTIONS.md Infrastructure table:
| Component | Provider | Details |
|-----------|----------|---------|
| CDN/DNS | Cloudflare | - |
| WAF | Cloudflare | OWASP ruleset enabled |
| Hosting | Coolify | 8GB VPS |
| Database | PostgreSQL 16 | Coolify-managed |
| Backup | R2 | pg_dump, daily, 7-day retention |
| Deploy | Coolify webhook | On push to main |
REPORT
- Added: Health bundle
- Created: src/api/health.py
- Configured: Coolify health probe (HTTP, /health, 30s interval)
- Validated: Endpoint returns 200, DB check passes, cache check passes
- Response time: 45ms
Platform notes:
- Coolify probe configured via UI (manual step documented)
If secrets/manual steps required:
Required setup:
1. In Coolify dashboard, set health check path to /health
2. Set health check interval to 30 seconds
3. Enable "Restart on unhealthy" option
If validation failures remain:
ACTION REQUIRED:
1. Database connectivity failing - check DATABASE_URL env var
2. Cache check timing out - verify Valkey is running
Rerun /infra after addressing these issues.
If all clean but bundles remain:
Note: more bundles remain, they will be added in future runs!
Recommendation: Run /documents
If all 4 bundles configured and validated:
All infrastructure configured and validated.
Recommendation: Run /documents
INFRA PREVIEW (DRY RUN)
Stack detected:
- CDN: Cloudflare
- Platform: Coolify
- Database: PostgreSQL 16
- Cache: Valkey
Configured: Health, Security
Missing: Backup, Deploy
Would add: Backup
Would create: scripts/backup.sh
Would configure: Cron schedule (daily 02:00 UTC)
Would store: Cloudflare R2 (bucket: backups)
Required setup:
- R2_ACCESS_KEY_ID in environment
- R2_SECRET_ACCESS_KEY in environment
Run without --dry-run to apply.
Cloudflare:
Coolify:
Vercel:
AWS/ECS: