Goal
Keep services, databases, buckets, domains, jobs, network rules and deploy settings in your repository, and have each push apply them safely.Prerequisites
- An application with at least one service connected to a GitHub repository.
- The StackShift CLI if you want to validate and plan from your machine.
- Secrets you reference by name already saved in StackShift. The file never holds secret values.
Workflow
1
Create the file with
stackshift init --name APP, or download one from a running app with Export stackshift.yaml.2
Add the schema line at the top of the file so your editor checks it as you type.
3
Run
stackshift validate --local to check the file without contacting StackShift.4
Run
stackshift plan to see each change and its class.5
Commit the file to your project root, or the repository root. Turn on Apply stackshift.yaml on push if it is not already on.
6
Push. Automatic changes apply at once, approval changes and the release wait for you in the dashboard, and blocked changes fail the release with the file and line.
What the file does
Onestackshift.yaml describes the whole application: its services, databases, buckets, domains, scheduled jobs, network rules and how it deploys. StackShift reads it on every push, plans the changes, applies the safe ones and holds the rest for you.
The file keeps the same format as before: apiVersion: stackshift.com/v1, kind: Application. Files you already have keep working. Unknown fields are rejected, so an older CLI fails clearly on a newer file.
Where the file lives
- StackShift looks in the service project root first, then the repository root.
- The name can be
stackshift.yamlorstackshift.yml. - With no file, pushes behave exactly as they did before.
Editor checks and local validation
Put this line first in the file. Editors that support the YAML language server then suggest fields and flag mistakes. The CLI uses the same schema offline.Full example
This file runs a Next.js app on your own server with a database, a bucket, two domains, two scheduled jobs and a staging environment. IDs and names are placeholders.stackshift.yaml
Deploy settings
These sit underservices.<name>.deploy. Durations are written like 30s or 2m.
strategy:rollingstarts the new copy, checks it, then stops the old one. It is the default.recreatestops the old copy first, so there is a short pause, and it fits small servers.autouses rolling when the server has room and recreate when it does not.health:path,interval,timeout,startupGraceandfailureThreshold. With only a path, the usual defaults apply for the rest.release: a list of commands that run once per release, before traffic moves to the new copy. They run in a one-off container from the new image, with the service variables and bindings. Database migrations belong here. If one fails, the release stops and the old copy keeps serving.
Capacity check
The plan checks whether the server can run the new copy next to the old one before anything builds. Underrolling, a deploy that does not fit is blocked. Under auto, the plan says it will use recreate, with the memory it needs and the memory the server has, and no approval is needed. Choosing recreate in the file is your consent to the short pause.
Environment variables and secrets
Each entry underenv is one of these:
- A plain string. It is a public value.
{ value, public: true }. The same, written out.{ secretRef: NAME }. A secret stored in StackShift, by name. The value never appears in the file.{ fromEnv: NAME, secret: true }. A value read from your env file or shell when you runstackshift apply. Withoutsecret: true, it stays public.scope:build,runtimeorboth. The default isruntime, andbothfor browser-public names such asNEXT_PUBLIC_*.secrets.required: a list of secret names. The deploy waits until each one exists.
References in values
Plain values and job headers can point at other things with${{ ... }}, for example ${{ secrets.CRON_SECRET }}, ${{ services.web.url }} or ${{ databases.main.host }}. References resolve at every deploy. A reference that cannot resolve is an error in the plan, never a literal string.
Use bindings to connect a service to a database or another service. A binding also handles private networking, the certificate and pooling.
Network rules
These sit underservices.<name>.network for web services.
redirects: a host to{ to, status }.headers:hsts,frame(DENYorSAMEORIGIN),nosniffandrobots.rateLimits: a list of{ name, paths, methods, limit, key }. A limit looks like20/1m, andkeyisip.cache.purgeOnDeploy: clear the edge cache when a release goes live.- If a server cannot serve a rule, the plan blocks the change for that server. It is never skipped quietly.
Alerts
Each entry underservices.<name>.alerts watches one number for that service and tells you when it stays too high. Stackie On Call checks it, so an alert shows up with your other on-call findings.
metric:cpu,memory,diskor5xxare percentages.diskis the server’s disk, and5xxis the share of requests that end in a server error.restartscounts how many times the service restarted.above: the alert fires when every reading stays above this number. Forrestarts, it fires when the count goes over it.for: how long the value must stay high, as a duration like5m. The default is2m.cooldown: after an alert clears, how long to stay quiet before it can fire again, like30m. The default is no wait.channels: where to send it:inbox,emailorslack, using the channels you already set up for on-call. The default isinbox.- When the value drops back down, you get one more message saying it recovered.
- Alerts are part of the service, so changing them is an automatic change. Remove an alert from the file to stop it.
Databases and buckets
Name a database or bucket in the file and StackShift creates it if it is missing. Usename to adopt one that already exists. A plain reference by name or ID, as in earlier files, still works.
- Databases:
engine,version,sizeGB,tier,backups(schedule,keep),standby,pooler,publicandname. Theengineandversioncannot change after creation. - Buckets:
name,public,corsandlifecycle. - Sizes use units, such as
512mband2gb.memoryMBandcpuMillicoresstill work.
Scheduled jobs
Each job underjobs is either http or command. An http job calls a path on one of your services, or a full URL, with optional headers that can use ${{ secrets.NAME }}. A command job runs a command in a service image.
A job can set schedule, timezone, timeout, retries, backoff, overlap and enabled. overlap is skip, queue or allow, and defaults to skip. Put shared settings under jobDefaults so you write them once.
Jobs wait while their service is deploying or has no healthy copy, so a deploy never makes them fail. If a job fails for 30 minutes, on-call switches it off.
If an HTTP cron job with the same name already exists, the file adopts it instead of creating a second one. The older cronJobs key still works and reads as command jobs.
Environments and previews
environments.<name>.branchPatternpicks the branch an environment follows.inheritFromstarts an environment from another one. The chain must lead back toproduction.services.<name>under an environment can override any service field. Lists replace the base list rather than merge with it.environments.previewapplies to pull request previews. It can only overridebuild,deployandenv, and a preview never creates databases, buckets or domains.
Apply on push
On a push to a branch an environment follows, StackShift reads the file at that commit, checks it, plans the changes and sorts them into three classes. Automatic changes apply. Approval changes are held for the owner. Blocked changes fail the release, and each error names the file and line. Apply stackshift.yaml on push is on by default for apps created from a file. For other apps it is a switch in the application settings. With the switch off, or no file in the repository, pushes behave as they did before.Change classes
Every change in a plan has one class.- Automatic: build and start commands, port, non-secret variables, health, strategy, release commands, job updates, network rules, scaling within your plan, and memory or CPU increases that fit your plan and the server.
- Approval: creating a service, database, bucket, domain or job; lowering memory or CPU; changing region, server or team; making a database public; adding a custom domain.
- Blocked: changing a database
engineorversion, changing a bucket region, shrinking a database or volume, and a rolling deploy that does not fit the server. - Not in stackshift.yaml: a resource you removed from the file. It is never changed or deleted by a push.
Approvals
When a push has approval changes, its automatic changes apply at once. The approval changes, anything that depends on them (such as a binding to a database that is waiting to be created), and the release wait for the owner as one request in the dashboard. Approving applies the held changes and runs the release. If the app changed since the plan, StackShift plans again first. Rejecting cancels the held changes and the release, and the automatic changes stay applied. A request that nobody decides on is cancelled the same way after 24 hours. Only the owner can approve, in the dashboard. Connected agents and Stackie read waiting requests withapplication_manifest_push_inspect (Stackie: inspect_manifest_push). It returns each plan, when it expires and review_url, the dashboard page where the owner decides. The agent gives the owner that link, then reads the request again with its run_id until settled is true.
Resources are never deleted by the file
Taking a database, bucket, domain, job or service out of the file does not delete it. The plan lists it under Not in stackshift.yaml. To delete it, usestackshift apply --prune or delete it in the dashboard. Only the owner can do either.
Pull request plans
For each pull request that changes the file or the code, StackShift posts the plan as a GitHub check. It shows the changes by class, the monthly cost difference, the capacity result and any resources the file does not list. Nothing is applied until the change reaches a followed branch.In the dashboard
- A field set in the file is read-only and shows a Managed by stackshift.yaml badge. Fields the file does not set stay editable.
- The Drift view lists dashboard values that differ from the file.
- Export stackshift.yaml downloads a file from a running app. Secret values are left out.
Expected result
The application matches the file. Changes that cost money, open public access or shrink a resource wait for your approval, and nothing is ever deleted because it left the file.
Common failures
Related guides
Application manifest schema
Define one application, its services, environments, bindings, attached resources, cron jobs, and domains.
Initialize, validate, plan, apply, and export
Use the application manifest lifecycle with stale-plan protection, explicit pruning, and optional deployment.
Build a multi-service application
Create an application, add public and private services from one repo or many, and let each service deploy independently while sharing one private network.
Scheduled jobs (cron)
Run a command from your deployed image on a recurring standard-cron schedule, with run history and exit-code tracking.
Application previews and promotion
Review pinned code in a dedicated Application with fresh PostgreSQL data, then approve cleanup or a separate parent release.