background-Codex-worktree-absolute-path-launch
Prevent overnight/background Codex worker launch failures in git worktrees by using absolute prompt/log paths and immediate post-launch polling.
Best use case
background-Codex-worktree-absolute-path-launch is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Prevent overnight/background Codex worker launch failures in git worktrees by using absolute prompt/log paths and immediate post-launch polling.
Teams using background-Codex-worktree-absolute-path-launch should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/background-claude-worktree-absolute-path-launch/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How background-Codex-worktree-absolute-path-launch Compares
| Feature / Agent | background-Codex-worktree-absolute-path-launch | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Prevent overnight/background Codex worker launch failures in git worktrees by using absolute prompt/log paths and immediate post-launch polling.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Background Codex Worktree Absolute-Path Launch Use when: - launching `Codex -p` in the background via Hermes `terminal(background=true)` - running overnight worker waves from a git worktree - the prompt file lives under `docs/plans/overnight-prompts/...` ## Symptom The background process exits immediately with an error like: ```text bash: docs/plans/.../worker-N.md: No such file or directory ``` This can happen even when `terminal(..., workdir=...)` points at the correct worktree and the prompt file really exists. ## Cause For unattended/background launches, relative prompt-file or log-file paths are less reliable than they look. In a worktree launch, shell expansion / file redirection may resolve the relative path unexpectedly before the process does useful work. ## Fix Always use absolute paths for: 1. the prompt file read into `PROMPT=$(< ...)` 2. the `tee` log destination 3. any other launch-critical file arguments Preferred pattern: ```bash PROMPT=$(< /abs/path/to/worker.md) Codex -p \ --permission-mode acceptEdits \ --no-session-persistence \ --output-format text \ --max-budget-usd 20 \ "$PROMPT" </dev/null | tee /abs/path/to/worker.log ``` ## Hermes background-process launch rule When launching a Codex worker from Hermes, do **not** wrap the shell command with `nohup`, trailing `&`, `disown`, or `setsid` in a foreground `terminal()` call. Hermes rejects shell-level background wrappers and cannot track them reliably. Use the tool's native background mode instead: ```text terminal( background=true, notify_on_complete=true, workdir="/abs/path/to/worktree", command="Codex --print --dangerously-skip-permissions < /abs/path/to/prompt.md" ) ``` For approved issue implementation/landing work where a user asks to "use a subagent", prefer this real background Codex process over `delegate_task`; it writes to the intended checkout and can commit/push, while `delegate_task` may lose repo writes. First verify the issue number exists before dispatching; if the requested number is missing but the current active issue is obvious, state the correction in the worker prompt and proceed only on the verified active issue. ## Verification step Immediately poll the background process once after launch. Healthy early signal: - process status is `running` - no immediate `No such file or directory` output Failure signal: - process status is `exited` - output preview shows missing prompt path or missing log path Also persist a small run manifest immediately after launch (for example `logs/overnight/<run>/RUNNING.md` or a shell transcript) with: - issue / terminal mapping - Hermes process session ID - OS PID, if available - prompt file path - log file path - expected result artifact path Hermes `process(action="list")` can return an empty process list even while direct polling by a known `session_id` still reports `running`. Treat the launch-returned session IDs as authoritative and poll them directly. Do not relaunch solely because `process list` is empty or because Codex logs are still zero bytes; first check direct poll, OS PID liveness, and expected result artifact creation. ## Recovery If the first launch used relative paths and failed: 1. confirm the prompt file exists with a file search or `read_file` 2. relaunch using absolute prompt and log paths 3. poll again right away before assuming the overnight wave is healthy ## Scope This is a launch-hygiene fix for planning or implementation waves. It does not replace the other unattended-run requirements: - `--permission-mode acceptEdits` for write-capable runs - prompt passed as a positional argument when stdin is closed - worktree isolation for zero git contention
Related Skills
digitalmodel-worktree-test-execution-with-shared-venv
Run digitalmodel tests from isolated worktrees without uv editable-dependency failures by using the main repo's existing virtualenv and PYTHONPATH.
blender-worktree-test-hardening
Recover and harden digitalmodel Blender automation work in isolated worktrees when uv/editable dependency paths break and local machines lack a Blender executable.
worktree-pre-push-bypass-for-tier1-checks
Handle workspace-hub integration-branch pushes from isolated git worktrees when the pre-push hook incorrectly assumes sibling tier-1 repos exist under the worktree path.
worktree-branch-sync-hygiene
Class-level branch, worktree, dirty-main, stash, sync, and hook hygiene for workspace-hub style multi-repo work.
verify-Codex-run-commit-vs-working-tree-before-closing
After a Codex implementation run, verify the claimed file set against the actual commit and working tree before treating the issue as fully complete.
python-import-path-mismatch-debugging
Diagnose and fix ModuleNotFoundError when a package is installed but imports still fail due to environment/path mismatches
python-import-path-debugging
Diagnose ModuleNotFoundError when a package is installed but still fails to import
git-worktree-cleanup-at-scale
Identify and remove stale git worktrees blocking branch deletion in multi-repo environments
git-worktree-cleanup-and-branch-reconciliation
Systematic process for cleaning up stale git worktrees, resolving merge conflicts in diverged branches, and reconciling branch state across multiple repositories.
git-worktree-cleanup-and-branch-hygiene
Systematic approach to cleaning up stale git worktrees, orphan branches, and branch hygiene at scale across multiple repos
extract-skills-from-Codex-sessions
Automatically extract reusable skills from Codex session transcripts using LLM analysis and wire them into a Stop hook
learned-git-worktree-hook-path-and-real-hook-shape-review
Catch hook-installation and governance bugs that only appear in linked git worktrees or against the real generated hook shape, not simplified test fixtures.