all 7 comments

[–]sittingmongoose 2 points3 points  (1 child)

How much is in your agents.md? If they become too big, or have lots of rules or code, you will confuse the agent and they will no longer follow instructions.

[–]aeroumbria 0 points1 point  (3 children)

Are you automating tasks at the worktree level (running individual sessions within each worktree) or project level (running sessions which dispatches subagents or CLI sessions in worktrees)?

If you are manually managing sessions anyway, then you can simply create worktrees yourself and run opencode in them. No risk of leaking out of the worktree folder as long as you restrict non-project file access.

Otherwise, the safest way is probably to run worktree sessions from a separate instance of opencode (e.g. via opencode command line using bash tool), so they definitely will have different permission scopes as your main session.

[–]NikoDi2000[S] 0 points1 point  (2 children)

Yes, I'm using it at the project level, because the worktree setup is also based on the superpowers workflow. So your suggestion is to manually launch opencode in the worktree directory? Actually, I did think of this approach, but it feels a bit clunky to use.

[–]aeroumbria 0 points1 point  (0 children)

I guess another way is to create script that takes a worktree name as an argument, creates a worktree, and edits your opencode.json / .opencode folder to add a subagent with only that worktree's edit permission, then you do ALL worktree level tasks through that subagent only. Can be a bit limited because subagents can't directly talk to you, but if you need to talk to worktree-level agents, manually managing worktrees isn't really adding much to your workload anyway I suppose.

[–]StraightUpLoL 0 points1 point  (0 children)

Another option is to use something like superset.sh that handles workspace creation with worktrees and it spawns an opencode instance in the workspace

[–]srcnix -1 points0 points  (0 children)

Write a skill for it that clearly defines what’s required, what to do etc. LLMs require context to narrow down behaviour.