📚 Encyclopedia

AI & Claude · updated 2026-10-26

claude-service (ProcrastinAI's webhook runner for headless Claude)

claude-serviceprocrastinaifastapiwebhookhmacautosshreverse-tunnelsystemdclaude-code

claude-service is a small, app-agnostic service that lets any registered app (TLDR, Forge, Stocks, ...) submit a prompt, get 202 Accepted immediately, and receive Claude's answer later on an HMAC-signed callback. It runs claude -p (headless Claude Code) on Justin's desktop, in a per-project working directory, and is what answers TLDR's AI posts as the persona ProcrastinAI. It replaced a TLDR-specific poller (poll_ai.py, every 2 minutes) in 2026-03.

Topology

App on the server (e.g. TLDR API, PHP)
  -> POST http://127.0.0.1:9100/request         (server side of the tunnel)
  -> autossh reverse tunnel -R 9100:localhost:9100
  -> claude-service on the desktop (:9100, FastAPI)
  -> claude -p in the project dir
  -> POST result to the app's callback URL (HMAC-SHA256 signed)

API

Registering an app or project

config.json (gitignored; template config.example.json) holds per-app API keys, callback secrets, and the project-to-directory map. register-app.sh only adds to apps; add the project to projects too or it will not show in /projects (found when adding Stocks). register-project.sh <name> <dir> registers an explicitly pickable project. Credentials live in that file and in each app's server-only config, never in git.

Example project, Stocks: a TLDR AI post tagged project=stocks runs Claude in ~/dev/stocks, whose CLAUDE.md says how to format quotes and whose .claude/settings.json allows ./tools/stock.sh SYMBOL (Finnhub /quote, free tier 60 req/min, 5-minute file cache in /tmp) and carries the Finnhub key in its env block. No TLDR schema or endpoint changes were needed.

The TLDR side

Behavior and conventions

Request options and execution details

Usage-limit hold (2026-09-06)

When the account hits its usage limit, the CLI prints the notice ("You've hit your session limit · resets 6:10am (America/Chicago)") as the JSON result on stdout and exits 1 with an empty stderr. Early on that surfaced as claude CLI exited with code 1: with no text. The service now: - builds error text from stderr, then the stdout JSON result/error, then raw stdout; - recognizes limit messages (including a ...limit reached|<epoch> form) and parses the reset time; - sets a global hold: every queue parks until reset + 30 s, held requests stay QUEUED with a held_until field on /status, and the failed attempt does not count against retries; - re-probes every 15 minutes (max 24 times) if the reset time cannot be parsed, and fails immediately (non-retryable) if the reset is more than 5.5 hours out. The TLDR expiry cron treats queued requests as alive for up to 6 hours.

Self-updating default model (2026-09-27, post #1688)

default_model in config.json is read fresh on every request (fallback opus) and reported as default by GET /models. A daily systemd timer runs update-default-model.py, which judges a newly released model and only switches (also updating ~/.claude/settings.json) on a high-confidence verdict; it supports --set, --dry-run, --force-judge and --seed. Code changes like this only take effect after a service restart, which kills every process in the unit's cgroup, so restarts are scheduled deliberately.

Gotchas

See also

Linked from

Sources: forge memory (claude-service.md, ai-activity.jsonl, tldr posts #1596, #1602, #1675), stocks memory ai-activity.jsonl, dev memory procrastinai-service.md, tldr-ai-webhook-integration.md, server-nginx-setup.md, home memory project_stocks, misc-side-projects (CNC builder, BiteCoin), global CLAUDE.md, claude-service memory (project_architecture, completed_work, feedback), tldr posts #1639, #1688, tldr memory (feature-ai-request-table, feature-ai-guest-mode), posts #1770, #1822, #1824