Skip to content

Background daemon

askshd is an optional local Unix-socket daemon that receives shell telemetry, runs background LLM tasks, and polls watched commands for failures.

Managing askshd

asksh daemon start
asksh daemon status
asksh daemon stop

The daemon listens on ~/.local/share/asksh/askshd.sock (mode 0600) and writes its PID to ~/.local/share/asksh/askshd.pid. If the socket path exceeds 96 bytes (the Unix sun_path limit), asksh automatically falls back to /tmp/askshd-<uid>.sock.

To run the daemon in the foreground instead of detaching (for example under systemd or launchd), use asksh daemon serve.

Background tasks (asksh bg)

Queue a headless task to run in the background on askshd:

asksh bg "audit disk usage under /var/log and suggest cleanup commands"

Pass --target <uri> to run against a remote host or container, or --dir <path> to set the working directory:

asksh bg --target "ssh://troy@greendale.edu" "check systemd units in failed state"

Background jobs use your config.toml, permissions.toml, skills, and memory settings, and persist job state to ~/.local/share/asksh/jobs/<job-id>.json.

Watching commands (asksh watch)

Poll a command on an interval and diagnose failures automatically when it breaks:

asksh watch --cmd "curl -fsS https://api.greendale.edu/health" --interval 30s --on-fail "check why the health endpoint failed"

Watch job behavior:

  • --interval defaults to 5s (minimum 1s).
  • Stdout and stderr from each tick are each capped at 64 KB.
  • When diagnosis runs: askshd invokes the LLM whenever a watched command transitions from exit code 0 to non-zero. If you pass --on-fail <prompt>, it also diagnoses a failure on the very first check. Consecutive failures while already failing do not trigger repeated LLM calls until the command recovers to exit 0 and fails again.

Inspecting and cancelling jobs

asksh jobs
asksh jobs logs job-a1b2c3d4e5f6
asksh jobs cancel job-a1b2c3d4e5f6

asksh jobs logs <id> prints the job status, target, command or prompt, exit code, error, output, and any generated diagnosis.

Shell prompt badge

Run asksh prompt in your shell prompt configuration to display active background jobs, watches, and alerts:

[asksh: 1 bg, 1 watch, 1 alert]

Alerts count failed jobs and active watch jobs whose most recent exit code is non-zero. asksh prompt exits within 50ms and outputs nothing when askshd is stopped or all counts are zero. See Shell integration for zsh, bash, and fish snippets.