codex exec background task rewrote an existing pre-commit hook shebang while asked to "preserve" it
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
Summary
Asked a Codex background task (codex exec --json, invoked via the Claude Code codex-openai-codex plugin) to add a small delegated call to an existing git pre-commit hook, explicitly instructing it to insert the new block right after the shebang line and leave everything else untouched. In 2 of 7 repositories, the existing hook was a pre-commit (https://pre-commit.com) generated script starting with #!/usr/bin/env bash. After Codex's edit, the file's first line had become #!/bin/sh instead of the original #!/usr/bin/env bash — the shebang itself was altered even though the instruction was to insert after it and preserve the rest.
Reproduction sketch
- Start from a file:
#!/usr/bin/env bash # File generated by pre-commit: https://pre-commit.com ... - Prompt: "insert this block right after the shebang line, do not touch anything else":
# MARKER:START ... # MARKER:END - Expected: line 1 stays
#!/usr/bin/env bash, block inserted as line 2. - Observed: line 1 became
#!/bin/sh.
I don't have the exact prompt/transcript to share publicly (it was proxied through another agent's orchestration), but wanted to flag the behavior in case it's a known class of issue with shebang-adjacent edits.
Secondary observation (same run)
In the same task, a loop over multiple repos calling attrib.exe (Windows) consumed the loop's stdin, causing only the first repo's target folder to be processed per iteration — the agent noticed this itself mid-task and redid the affected repos. Not filing this as a primary bug (looks like a known bash/Windows-tool stdin-consumption gotcha), just noting it happened in the same session in case it's useful context.
Environment
- Windows 11, Git Bash,
codex exec --json --sandbox workspace-writevia the Claude Code plugincodex-openai-codex
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the edit with codex exec --json --sandbox workspace-write in Git Bash, using the supplied pre-commit example and insertion instruction. Compare the original and edited shebangs across repositories; done means inserting the block after the shebang without changing that line or other existing content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, git, rust
- Domain
- cli, devtools, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100