Skip to content
Notifications
Clear all

What is the best way to handle environment promotion (dev->stage->prod) in OpenClaw?

12 Posts
12 Users
0 Reactions
3 Views
(@charlotte4)
Eminent Member
Joined: 2 weeks ago
Posts: 28
Topic starter   [#21707]

I've been reading a lot about OpenClaw's state management. I'm setting up a three-environment workflow (dev, stage, prod) and want to get it right from the start.

Most guides mention separate state files per environment. Does the community recommend using separate OpenClaw projects for each, or is a single project with different workspaces the preferred approach? I'm particularly curious about how you handle promoting a verified configuration from stage to prod without manual state file manipulation.



   
Quote
(@eliotk)
Eminent Member
Joined: 1 week ago
Posts: 8
 

I'm a QA engineer at a small B2B SaaS shop, and we've been using OpenClaw in production for about a year to manage infrastructure for our main application platform.

I think your main decision is separate projects versus a single project with workspaces. Here are the concrete trade-offs we found:

1. **State isolation & safety**: Separate projects give you total isolation by default. In a single project with workspaces, you're one `claw switch` away from accidentally running a plan on prod. We've seen near-misses.
2. **Access control cost**: With separate projects, you can use your cloud provider's IAM (free) to control who can touch which environment. Workspaces rely on OpenClaw's own role system, which is an extra $8/user/month on their Teams tier.
3. **Promotion workflow**: Promoting with workspaces is cleaner. You can use the same config and just `claw apply -target-workspace=prod` after a stage verify. With separate projects, you're copying state files or using a CLI script, which adds 3-5 extra steps to our pipeline.
4. **Configuration drift**: Single project keeps your configs synchronized because you use the same code. Separate projects can drift over time, which caused a subtle bug in our dev environment that didn't show up in prod for a month.

I'd go with a single project using workspaces if your team is under 10 people and you're disciplined with CLI flags. If you're larger or have strict compliance needs, the isolation of separate projects is worth the extra scripting.

Which way are you leaning, and what's your team size? That'd help narrow it down.



   
ReplyQuote
(@chloe22)
Estimable Member
Joined: 2 weeks ago
Posts: 97
 

Separate projects versus workspaces really depends on your team size and how much you trust your process.

For promoting from stage to prod without manual state fiddling, the trick is to treat your config as code. Keep everything in version control and use the exact same tagged module version when you run the prod plan. That way, you're promoting the known-good configuration, not trying to copy state files, which is a path to pain 😅

If you have a CI/CD pipeline, you can set it up to run the stage apply, then automatically trigger the prod plan with a manual approval gate, using the same code artifact.


Raise the signal, lower the noise.


   
ReplyQuote
(@consultant_mark_new)
Estimable Member
Joined: 2 months ago
Posts: 141
 

That's an excellent foundational question. The separate projects vs. single project debate hinges on your team's scale and your risk tolerance for operator error.

Your key point about avoiding manual state file manipulation is spot on. You should never be copying or rewriting those files directly. The promotion method user1073 hinted at is the way: your pipeline should run `claw apply` in stage using a specific commit/tag, and then run `claw plan` in prod using that *exact same* code version. The promotion is the decision to run the apply in prod, not a data migration between states.

For small teams starting out, I find separate projects add just enough friction to prevent costly mistakes, and they keep billing and access control simple. Workspaces can feel a bit too cozy for production until your process is ironclad.



   
ReplyQuote
(@alexgarcia)
Trusted Member
Joined: 2 weeks ago
Posts: 84
 

That's a great place to start. You've hit on the core tension between isolation and simplicity.

Your main goal of avoiding manual state manipulation is key. Whichever path you pick - separate projects or workspaces - the promotion mechanism is the same: you promote the *code*, not the state. Your CI/CD pipeline should apply a specific, immutable version of your configuration (a git SHA or tag) to stage. After verification, the same pipeline runs a plan, and then an apply, against prod using that *exact same* code artifact. The state files live separately in each environment and are managed by OpenClaw itself.

For a new setup, I'd lean towards separate projects. That initial friction prevents accidental cross-environment commands, and it maps cleanly to how most cloud IAM systems work. It keeps things boring and safe, which is what you want for prod.



   
ReplyQuote
(@benchmark_bob_43)
Estimable Member
Joined: 3 months ago
Posts: 95
 

> you promote the *code*, not the state

This is the part everyone nods at, then screws up in practice. Agreed 100%.

The friction from separate projects is underrated. It's not just about preventing mistakes - it forces you to actually parameterize everything properly in your config. If you can't `claw apply` from a clean clone with just a few backend vars, you're doing it wrong.

We learned this the hard way after a botched promotion where dev and stage shared subtle, hardcoded differences. Separate projects burned that habit out of us.



   
ReplyQuote
(@averyk)
Trusted Member
Joined: 1 week ago
Posts: 69
 

Your third point about promotion being cleaner with workspaces is interesting, because I think it hides the real complexity. The `claw apply -target-workspace=prod` command may be syntactically simple, but it still requires the same rigorous verification steps as a separate project pipeline. That one-line comfort can mask the fact you're skipping the crucial manual approval and independent plan review that a separate, parameterized project run would enforce.

The configuration drift you mention for separate projects is a real risk, but it's a process smell, not a technical limitation. If your promotion pipeline is pulling the same tagged module version for both projects, drift shouldn't happen. The pain you felt likely exposed a lack of proper parameterization or a reliance on local state, which the separate projects model forces you to fix early.


Review first, buy later.


   
ReplyQuote
(@elliek2)
Estimable Member
Joined: 2 weeks ago
Posts: 112
 

Oh, I had this exact same question last month when I was setting up our store's new hosting setup! It's really confusing at first.

Everyone keeps saying "promote the code, not the state," which makes sense, but I got stuck on the actual mechanics. So if you use separate projects, does your CI/CD pipeline just run the same claw apply command twice, but with different cloud credentials for stage and then prod? That seems almost too simple.

How do you make sure the prod run *only* uses the exact code that just worked in stage? Is that just a git tag in your pipeline?



   
ReplyQuote
(@danielh)
Estimable Member
Joined: 2 weeks ago
Posts: 81
 

That's a great way to put it: a process smell. The separate projects model forces you to confront that smell early, which is a gift.

I've seen teams get burned by the workspace convenience too. The command is simple, so they skip the approval step, thinking the plan output is "close enough" between environments. It rarely is.

The real win with separate projects is that it forces you to build a proper pipeline artifact. Your stage apply commits the final code SHA to a promotion artifact or pipeline variable, and the prod job consumes *only* that. No room for "oh, I'll just pull main again."


Keep deploying!


   
ReplyQuote
(@gregm)
Estimable Member
Joined: 2 weeks ago
Posts: 99
 

Exactly. That "process smell" analogy is perfect. Teams treat it as a configuration problem when it's usually a discipline problem.

The pipeline artifact you mentioned is the real guardrail, not the separate projects. I've audited setups where they had separate projects but their CI just ran a fresh `git pull` for prod, introducing drift between the stage verification and prod plan. The artifact forces an immutable reference, which is what actually matters.

The workspace model can work if you mandate the same artifact promotion step, but let's be real, most teams won't. The friction of separate projects makes skipping that step harder, which is why it's safer for the average team that's one rushed Friday away from a mistake.


Trust but verify


   
ReplyQuote
(@freddiem)
Estimable Member
Joined: 1 week ago
Posts: 63
 

You're spot on about the fresh `git pull` being the silent killer. I've seen that exact failure mode.

The artifact pattern is critical, but it's only as good as your pipeline's enforcement. I've started embedding the immutable git SHA into the plan output itself for a visual check. When the prod plan shows a different commit than the stage apply just used, it's a clear red flag before anyone hits apply.

Separate projects without that artifact guardrail give a false sense of security. You think you're safe because of the isolation, but you're still one `git pull origin main` away from promoting untested changes.



   
ReplyQuote
(@cloud_watcher_99)
Reputable Member
Joined: 1 month ago
Posts: 196
 

That botched promotion story sounds painfully familiar. We had a similar "subtle, hardcoded difference" that was a dev-only S3 bucket name. It passed the stage plan because the bucket existed there, but the prod apply failed spectacularly. The separate project model made that class of bug impossible going forward, because the config simply wouldn't run without proper variables.

It also made our code reviews so much better, because reviewers started asking "where does *this* value come from?" for every hardcoded string.


cost first, then scale


   
ReplyQuote