Deploy With Claude Code
Why deploy with Claude Code?
Most deployments follow the same pattern: commit, push, wait, check. But between "push" and "check" is where things go wrong. A broken build, a missing environment variable, a regression on the checkout flow, a page that returns 500. You find out 20 minutes later when a user reports it.
Claude Code turns deployment from a push-and-pray operation into a verified pipeline. It can run pre-deploy checks before pushing, trigger the deployment, monitor the build, and verify the live site after deployment completes. All from your terminal, all in one workflow.
The basic deployment workflow
At its simplest, deploying with Claude Code looks like this:
Commit these changes, push to main, and verify the deploy succeeds
Claude will:
- Stage and commit your changes with an appropriate message
- Push to the remote branch
- Check if a CI/CD pipeline triggered
- Report back with the deployment status
That alone saves context switching. But the real value comes from building checks around the push.
Pre-deploy checks
The most valuable part of a Claude Code deployment workflow is what happens before the push. Build a pre-deploy checklist and Claude runs through it every time:
Linting and type checking
Run the linter and type checker before we deploy
Claude runs npm run lint, npx tsc --noEmit, or whatever your project uses. If anything fails, it reports the issues and offers to fix them before continuing.
Test suite
Run the test suite and only push if everything passes
Claude runs your tests, interprets failures, and can even fix failing tests if the issue is straightforward. No more pushing code that breaks CI because you forgot to run tests locally.
Build verification
Run a production build locally before pushing
A local npm run build catches most build errors before they hit CI. Claude runs it, checks for warnings and errors, and blocks the push if something fails.
Security scan
Check for any hardcoded secrets or exposed API keys in the changes
Claude reviews the diff for common patterns: API keys, tokens, passwords, connection strings. A quick grep-based check that catches the mistakes that haunt you at 2 AM.
Building a deploy command
Wrap all pre-deploy checks into a single command:
---
description: Deploy with pre and post verification
allowed-tools:
- Bash
- Read
- Grep
- Glob
---
Run the full deploy pipeline:
## Pre-deploy checks
1. Run `npm run lint` -- fail if errors
2. Run `npx tsc --noEmit` -- fail if type errors
3. Run `npm run test` -- fail if test failures
4. Run `npm run build` -- fail if build errors
5. Check git diff for hardcoded secrets (API keys, tokens, passwords)
6. If any check fails: report the issue and STOP. Do not push.
## Deploy
7. Stage all changes
8. Commit with a descriptive message
9. Push to main
## Post-deploy verification
10. Wait 60 seconds for the build to complete
11. Check the live URL returns 200
12. Verify key pages load correctly
13. Report deployment status: PASS or FAIL with details
Now /deploy runs the entire pipeline. One command, full verification, every time.
Platform-specific deployment
Vercel
Vercel deploys automatically on push to main. Claude Code works well with this model:
Push to main and then check the Vercel deployment status
Claude pushes, then monitors the deployment. If you have the Vercel CLI installed, Claude can check build status directly:
npx vercel ls --limit 1
For preview deployments on branches:
Push this branch and get the Vercel preview URL
Claude pushes, waits for the preview build, and returns the URL for review.
Railway
Railway also deploys on push. Claude can interact with the Railway CLI:
railway status
railway logs --latest
A deploy command for Railway might include checking the deployment health endpoint after push:
Push to main, wait 90 seconds, then curl the health endpoint at api.myapp.com/health
Netlify
Same pattern. Push triggers a build, and Claude can verify:
netlify status
netlify deploy --prod
For Netlify, Claude can also run netlify deploy --prod directly if you prefer explicit deploys over git-triggered ones.
Self-hosted / SSH
For servers you manage directly, Claude can handle the full SSH deployment:
SSH into the production server, pull the latest changes, run the build, and restart the service
Claude executes each step, checking for errors between them. If the build fails, it does not restart the service with broken code.
Post-deploy verification
Pushing is half the job. Verifying the deploy landed correctly is the other half.
HTTP health checks
The simplest verification is hitting your live URL:
curl -s -o /dev/null -w "%{http_code}" https://myapp.com
Claude checks the status code. 200 means success. Anything else triggers investigation.
Page content verification
Go beyond status codes. Check that critical content is actually present:
curl -s https://myapp.com | grep -c "Sign Up"
curl -s https://myapp.com/pricing | grep -c "$49"
This catches the case where the page loads but critical content is missing due to a build error or data issue.
Checkout and critical flow testing
For e-commerce or SaaS sites, verify the money path works:
After deploying, verify that:
1. The homepage loads with the pricing section
2. The pricing page shows both tiers
3. The checkout button links to the correct Stripe URL
4. The success page loads
Claude can use browser automation (via Playwright MCP) or simple curl checks to verify each step.
Regression detection
Compare key metrics before and after deployment:
Check the bundle size before and after this deploy.
Flag if any chunk increased by more than 10%.
Claude runs the build analyzer, compares the output, and alerts you to unexpected size increases that could affect performance.
CI/CD integration with hooks
Claude Code hooks can enforce deployment rules automatically:
Block pushes without tests
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash(git push*)",
"type": "command",
"command": "check-tests-passed.sh"
}]
}
}
This hook runs before any git push command, verifying that tests passed first. If the check script returns non-zero, the push is blocked.
Log every deployment
{
"hooks": {
"PostToolUse": [{
"matcher": "Bash(git push*)",
"type": "command",
"command": "log-deployment.sh"
}]
}
}
Every push gets logged with a timestamp, branch, commit hash, and who triggered it. Essential for debugging "when did this break?" questions.
Environment safety
Prevent accidental pushes to production from the wrong branch:
#!/bin/bash
# pre-push-safety.sh
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "main" ] && echo "$@" | grep -q "origin main"; then
echo "BLOCKED: Cannot push non-main branch to origin/main"
exit 1
fi
Rollback workflows
When a deploy goes wrong, Claude can handle rollbacks:
The deploy broke the checkout flow. Revert the last commit and push.
Claude runs git revert HEAD, pushes the revert commit, and verifies the fix deployed correctly. No force pushes, no history rewriting, clean audit trail.
For more complex rollbacks:
The last 3 commits introduced a regression. Create a revert branch,
revert all 3, push, and verify.
Claude handles the git operations, creates a clean revert branch, and runs the full post-deploy verification.
Environment variable management
Missing environment variables are a top cause of deployment failures. Claude can help:
Compare the env vars in .env.local with what's set in Vercel.
Flag any that are missing from production.
Claude reads your local env file (without logging values), checks the Vercel project settings via CLI, and reports discrepancies. This catches the classic "works locally, breaks in production" scenario.
Multi-environment deployments
For projects with staging and production environments:
---
description: Deploy to staging with full verification
---
1. Push to the staging branch
2. Wait for the staging build
3. Run the full test suite against staging.myapp.com
4. If all checks pass, report "Staging verified - ready for production"
5. If any check fails, report the failure and do NOT proceed
Then a separate /deploy-prod command handles the staging-to-production promotion with its own verification suite.
Deployment as part of your workflow
The best deployment setup integrates with your daily git workflow. A typical pattern:
/startloads context and picks up the current task- Work on the feature, test locally
/deployruns the full pipeline: checks, push, verify- If verification fails, Claude diagnoses and fixes
/deployagain after the fix
The deployment command becomes just another step in your workflow, not a separate process requiring context switching to a CI dashboard.
Claudify ships with a /deploy command that includes pre-checks (lint, types, build, secrets scan), post-verification (HTTP checks, content verification), and deployment logging. It works with Vercel, Railway, Netlify, and any git-triggered deployment platform out of the box.
FAQ
Can Claude Code deploy to any platform?
Claude Code works with any platform that deploys via git push (Vercel, Railway, Netlify, Render, Fly.io) and any platform with a CLI tool (AWS, GCP, Azure, Heroku). For platforms without git-triggered deploys, Claude can run the platform CLI directly. If you can deploy from a terminal, Claude can automate it.
Is it safe to let Claude Code push to production?
With proper safeguards, yes. Use pre-push hooks to enforce test passage, branch protection to prevent direct pushes to main without review, and post-deploy verification to catch regressions. The deploy command pattern described above is safer than manual deployment because it never skips checks, even when you are in a hurry.
How do I handle deploy failures automatically?
Build failure handling into your deploy command. If post-deploy verification fails, the command should automatically create a revert commit and push it. Then it notifies you with the failure details. Claude can also check CI logs to diagnose why the build failed and suggest fixes before you retry.
Start deploying smarter
Begin with a simple deploy command that runs your linter and tests before pushing. Add post-deploy checks once that is working. Layer in hooks for automated enforcement. The goal is zero manual deployment steps between "code is ready" and "code is verified in production."
Get Claudify -- Deployment commands, hooks, and 9 agents. Installed in one command.
More like this
Ready to upgrade your Claude Code setup?
Get Claudify