AGENT SKILL

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

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 ...
  • python3 can also be python3.N or 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