Merge pull request #747 from trek-e/fix/733-bash-ampersand-hang

fix: add anti-pattern rule against bash with & to prevent agent hangs (#733)
This commit is contained in:
TÂCHES 2026-03-16 18:38:40 -06:00 committed by GitHub
commit f4f998efc5

View file

@ -154,7 +154,7 @@ Templates showing the expected format for each artifact type are in:
**External facts:** Use `search-the-web` + `fetch_page`, or `search_and_read` for one-call extraction. Use `freshness` for recency. Never state current facts from training data without verification.
**Background processes:** Use `bg_shell` with `start` + `wait_for_ready` for servers, watchers, and daemons. Never poll with `sleep`/retry loops — `wait_for_ready` exists for this. For status checks, use `digest` (~30 tokens), not `output` (~2000 tokens). Use `highlights` (~100 tokens) when you need significant lines only. Use `output` only when actively debugging.
**Background processes:** Use `bg_shell` with `start` + `wait_for_ready` for servers, watchers, and daemons. Never use `bash` with `&` or `nohup` to background a process — the `bash` tool waits for stdout to close, so backgrounded children that inherit the file descriptors cause it to hang indefinitely. Never poll with `sleep`/retry loops — `wait_for_ready` exists for this. For status checks, use `digest` (~30 tokens), not `output` (~2000 tokens). Use `highlights` (~100 tokens) when you need significant lines only. Use `output` only when actively debugging.
**One-shot commands:** Use `async_bash` for builds, tests, and installs. The result is pushed to you when the command exits — no polling needed. Use `await_job` to block on a specific job.
@ -169,6 +169,7 @@ Templates showing the expected format for each artifact type are in:
- Never use `cat` to read a file you might edit — `read` gives you the exact text `edit` needs.
- Never `grep` for a function definition when `lsp` go-to-definition is available.
- Never poll a server with `sleep 1 && curl` loops — use `bg_shell` `wait_for_ready`.
- Never use `bash` with `&` to background a process — it hangs because the child inherits stdout. Use `bg_shell` `start` instead.
- Never use `bg_shell` `output` for a status check — use `digest`.
- Never read files one-by-one to understand a subsystem — use `rg` or `scout` first.
- Never guess at library APIs from training data — use `get_library_docs`.