Skip to content

Execution

OpenClaw uses a worktree-first execution model. preqstation-openclaw prepares an isolated workspace, writes the PREQ prompt to disk, then launches the requested coding agent with a short bootstrap instruction.

Execution Flow

1. Parse message
→ engine key: claude-code / codex / gemini-cli (default: claude-code)
→ task ID (optional)
→ project key / absolute path
→ branch_name (optional)
→ objective
→ progress mode: sparse (default) or live
2. Resolve project_cwd
→ absolute path in message
→ OpenClaw agent memory
→ task-prefix key match
3. Create isolated worktree
→ git -C <project_cwd> worktree add -b <branch_name> <cwd> HEAD
4. Write full PREQ prompt
→ <cwd>/.preqstation-prompt.txt
5. Launch coding agent with bootstrap prompt
→ Claude: claude --dangerously-skip-permissions "Read and execute instructions from ./.preqstation-prompt.txt ..."
→ Codex: codex exec --dangerously-bypass-approvals-and-sandbox "Read and execute instructions from ./.preqstation-prompt.txt ..."
→ Gemini: GEMINI_SANDBOX=false gemini -p "Read and execute instructions from ./.preqstation-prompt.txt ..."
6. Monitor background process
→ list / poll / log / write / submit / kill
7. Clean up worktree
→ git -C <project_cwd> worktree remove <cwd> --force
→ git -C <project_cwd> worktree prune

Prompt Transport

OpenClaw does not pass the full PREQ prompt through argv or stdin.

Instead it:

  1. renders the full prompt into <cwd>/.preqstation-prompt.txt
  2. launches the agent with a short instruction telling it to read that file

This keeps long prompts out of shell history and avoids argument-length problems.

Bootstrap Prompt

All engines get the same idea:

Read and execute instructions from ./.preqstation-prompt.txt in the current workspace.
Treat that file as the source of truth.
If a Task ID is present there, call preq_get_task first, then preq_start_task before substantive work.

Engine Commands

Claude Code

Terminal window
claude --dangerously-skip-permissions "Read and execute instructions from ./.preqstation-prompt.txt in the current workspace. Treat that file as the source of truth. If a Task ID is present there, call preq_get_task first, then preq_start_task before substantive work."

Codex CLI

Terminal window
codex exec --dangerously-bypass-approvals-and-sandbox "Read and execute instructions from ./.preqstation-prompt.txt in the current workspace. Treat that file as the source of truth. If a Task ID is present there, call preq_get_task first, then preq_start_task before substantive work."

Gemini CLI

Terminal window
GEMINI_SANDBOX=false gemini -p "Read and execute instructions from ./.preqstation-prompt.txt in the current workspace. Treat that file as the source of truth. If a Task ID is present there, call preq_get_task first, then preq_start_task before substantive work."

Background Execution

OpenClaw should launch agents with pty:true and background:true by default.

Useful process actions:

process action:list
process action:poll sessionId:<id>
process action:log sessionId:<id>
process action:write sessionId:<id> data:"..."
process action:submit sessionId:<id> data:"..."
process action:kill sessionId:<id>

Lifecycle Handoff

OpenClaw should not redefine the PREQ lifecycle. It hands off task branching to the core preqstation skill.

The only execution-specific rule to remember here is:

  • if a task ID is present, call preq_get_task() first
  • call preq_start_task() before substantive work
  • then follow the branch defined in Task Lifecycle

Environment Constraints

The executing agent:

  • works only inside the per-task worktree cwd
  • must not modify the primary checkout directly
  • must use preq_* tools for lifecycle tracking
  • must clean up the worktree when finished

Output Format

Success:

completed: <task or N/A> via <engine> at <cwd>

Failure:

failed: <task or N/A> via <engine> at <cwd or N/A> - <short reason>

Example:

completed: PROJ-284 via claude-code at /tmp/openclaw-worktrees/proj/preqstation-proj-rate-limit