Articles

Let Claude Code deploy to production safely

Give Claude Code a Gregale agent key instead of your login or cloud credentials. It can deploy, read logs and roll back; risky production changes wait for your approval, new releases go to a small share of traffic first, and you can undo what it changed.

Updated

To let Claude Code deploy to production safely, give it a Gregale agent key instead of your own login or cloud credentials. It can then deploy, read logs and roll back on its own, while Gregale enforces the limits: risky production changes wait for your approval, new releases go to a small share of traffic before the rest, every change the agent makes is logged, and you can undo them.

Set it up

sh
curl -fsSL https://get.gregale.dev | sh
gregale login                              # you sign in once
gregale key create coding-agent --agent    # a key for Claude Code, not your login
gregale init --agents --name my-api        # deploy, check and rollback steps in AGENTS.md

Put the key in Claude Code's environment as GREGALE_TOKEN; it overrides your saved login for every gregale command. Don't paste it into a prompt or a committed file. This step matters: if Claude Code runs the CLI on your own login, Gregale treats it as you, and none of the guardrails below apply. Then ask Claude Code to deploy. Or connect Claude Code to Gregale's hosted MCP server (in preview) with gregale mcp connect --client claude-code, or install the Gregale plugin, which adds /gregale:deploy and /gregale:diagnose:

sh
claude plugin marketplace add poyrazK/faas-web
claude plugin install gregale@gregale

The guardrails, and where they live

RiskWhat Gregale does
The agent deletes or changes productionIt must ask first: you get a review link and approve the exact request (how)
A bad release reaches usersThe new version gets 1% of traffic first and rolls back on its own on errors (beta)
The agent changed more than codegregale mcp connection undo reverses settings, variables, scaling, crons and domains (how)
The agent runs up the billA per-agent budget prices always-on changes before they happen (how)
You need to know what it didgregale mcp connection activity lists every write for 7 days, with the reason the agent gave
Secrets leak into the sessionThe agent key is scoped; it never needs your login or a cloud provider's keys

Because these checks are in Gregale's API, they hold for every request the agent key makes, including commands you let Claude Code run without reading closely.

What Claude Code does on Gregale

The CLI is built for agents: --non-interactive never prompts or opens a browser, and --json errors carry a stable code. A typical loop:

sh
gregale deploy --dry-run                                     # what Gregale detects in this repo
gregale --non-interactive --json deploy --name my-api
gregale --non-interactive --json app health my-api --errors  # after a failed deploy
gregale --non-interactive --json rollback my-api

How other setups compare

The usual advice for letting a coding agent near production is: give it least-privilege credentials, put a human approval step in front of production, and make rollback easy. On most platforms you assemble that yourself from the agent's permission settings, a CI pipeline with a required reviewer, and a separate deploy role. Gregale builds those controls into the platform, so they apply to every request the agent's key makes.

Questions

Does Claude Code need my cloud credentials?

No. It gets its own Gregale agent key, or connects to Gregale's hosted MCP server (in preview) with OAuth. You never paste your own login or a cloud provider's keys into the session.

What can Claude Code do without asking?

Inspect apps, read logs and metrics, and deploy previews. Deletes, production deploys and rollbacks, credentials and billing changes wait for your approval unless you choose otherwise.

What if a deploy breaks production?

A production release gets 1% of traffic first, then 10%, 50% and 100%, and Gregale stops it when its 5xx rate, latency, crashes or memory get worse (progressive rollouts are in beta). gregale mcp connection undo reverses everything else the agent changed.

Does this work with Codex, Cursor or Gemini CLI?

Yes. They use the same CLI and agent key, and any MCP client can connect to the hosted MCP server. Gregale has a setup guide for each.