agentleFS
syangasyanga/astack/skills/run-job/SKILL.md

run-job

Skill0 starsChanged 55 days agoMITView on GitHub

Run a command in its own process group and stop the whole group at a deadline, on a signal, or when the command exits.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    when the helper receives SIGINT, SIGTERM, or SIGHUP,

    line 14
  2. Distinctive:

    when the command exits and leaves other processes running in its group.

    line 15
  3. Distinctive:

    Run a finite job with a deadline well past its normal duration:

    line 17
  4. Very specific:

    Run a long-lived process, such as a dev server, with --no-timeout.

    line 23
  5. Distinctive:

    Before you end the turn, read that first check in the output and confirm it ran without errors.

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Run a bounded job

A background command that hangs never exits, so the notification that waits for its exit never arrives. scripts/run_job.py runs a command in its own process group. It stops the whole group:

  • at the deadline,
  • when the helper receives SIGINT, SIGTERM, or SIGHUP,
  • when the command exits and leaves other processes running in its group.

Run a finite job with a deadline well past its normal duration:

python3 <skill-directory>/scripts/run_job.py --timeout 1800 -- make test

Run a long-lived process, such as a dev server, with --no-timeout. The helper still exits when the process exits or crashes:

python3 <skill-directory>/scripts/run_job.py --no-timeout -- npm run dev

Pass the command as separate arguments. For pipes, redirections, or several commands, use sh -c '...'. Run the work in the command's foreground. If a launcher detaches its worker and exits, the helper stops the worker as a leftover process. Keep the project's test locks, worker limits, and execution wrappers.

The helper needs Python 3.9 or later. It inherits the current directory and environment, reads stdin from /dev/null, and passes stdout and stderr through. Its own status lines go to stderr and start with run-job:.

Exit codeMeaning
The command's codeThe command exited. A command killed by signal N gives 128+N.
2The arguments are invalid. Nothing started.
124The deadline passed, and the helper stopped the process group.
125The helper could not confirm that the process group stopped. This replaces any other code.
126The command is not executable.
127The command was not found.
128+NThe helper received signal N and stopped the process group.

A command can exit with one of these codes itself. The helper prints a run-job: status line with codes 124 through 127 and a usage: run_job.py line with code 2.

Bound a watcher and confirm its first check

A watcher waits for one outcome, such as a ready line or a CI result. Give it a deadline:

python3 <skill-directory>/scripts/run_job.py --timeout 5400 -- gh pr checks 42 --watch
  • Make the watcher exit on every outcome: success, failure, an error from the check itself, and the watched process ending. If the watched process runs through its own run_job.py call, that call's exit notification reports a crash. Stop the watcher when it arrives.
  • Make it print its first check before its first sleep. Keep the check's stderr in the watcher's output, since a check can print an error and still exit 0.
  • Before you end the turn, read that first check in the output and confirm it ran without errors.

Processes the helper cannot stop

A process that calls setsid leaves the group, and the helper does not stop it. The helper cannot handle SIGKILL, so killing the helper that way leaves the group running.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.