claude-background-jobs
Claude Code hook that denies background Bash commands that do not run through the run-job helper, or that the Bash tool would stop before the helper's deadline.
- License 许可
- MIT
- 所属仓库
- syanga/astack
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- claude-background-jobs
- description
- Claude Code hook that denies background Bash commands that do not run through the run-job helper, or that the Bash tool would stop before the helper's deadline.
- disable-model-invocation
- true
02 资源文件 1
- 脚本scripts/hook.py3.7 KB
03 SKILL.md 正文
Deny unbounded Claude Code background jobs
scripts/hook.py is a Claude Code PreToolUse hook for the Bash tool. It denies
a run_in_background call unless the command runs the helper from the
run-job skill, written literally:
python3 /absolute/path/to/run-job/scripts/run_job.py ARG ...
python3can also bepython3.Nor an absolute path to either name.- The helper path must be the installed
run_job.py, written as an absolute path. - Each word is made of letters, digits,
_ . / : = @ % + , -, and single-quoted text. Any other character, such as$,~, a double quote, or a newline, denies the call.
Put shell syntax and cd inside sh -c '...', and set variables with
env VAR=value. The deny message gives the command forms for a finite job and a
long-lived process, with the helper's absolute path.
The hook also denies a --timeout SECONDS job whose Bash tool timeout is below
(SECONDS + 30) * 1000. The tool's default is 1800000 ms, so the hook denies
--timeout 1800 with no tool timeout. The longest deadline is --timeout 7170,
because the tool allows at most 7200000 ms. The hook allows arguments the helper
rejects, because the helper then exits with code 2 and starts nothing.
The hook checks only the tool call. Shell functions and aliases in the user's shell setup, including zsh global aliases that expand inside arguments, can still change what runs.
The hook fails open. If the event is malformed, or the script or python3 is
missing, the hook exits with code 1. Claude Code reports the hook error and runs
the command.
04 同仓库更多 Skills
replace-with-skill-name
Replace with when this skill should be reached.
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
worktree-cleanup
Worktree cleanup. Use for cleanup, resource audits, close this lane, or close out.
wizard
Generate an interactive Bash wizard that walks a human through steps only they can perform. Use when provisioning, credential setup, or a one-off migration needs such steps.
why
Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Returns a cited read on decisions and tradeoffs.
wayfinder
Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.