How gtapps/claude-code-hermit works
Purpose and Repository Shape
This monorepo delivers Claude Code plugins centered on Hermit, a persistent, proactive, cost-aware agent runtime. The core plugin turns a local Claude Code installation into an operator-governed always-on agent; domain plugins extend it for development, Home Assistant, fitness, feeds, Laravel Forge, and GitHub issue filing. Plugin manifests are the installation entry points: plugins/claude-code-hermit/.claude-plugin/plugin.json and sibling plugin manifests.
Core Hermit Runtime
The primary executable surface is Bun/TypeScript scripts under plugins/claude-code-hermit/scripts/. Lifecycle commands start, stop, pause, and supervise the resident Claude session: scripts/hermit-start.ts, scripts/hermit-stop.ts, scripts/hermit-pause.ts, and scripts/hermit-watchdog.ts. Generated per-installation shell entry points and state templates live in plugins/claude-code-hermit/state-templates/bin/ and plugins/claude-code-hermit/state-templates/.
Setup, Configuration, and State Boundary
/hatch establishes an installation-specific .claude-code-hermit state area, scaffolds operator/state documents, and creates validated configuration. The orchestration path is scripts/domain-hatch.ts, scripts/hatch-config.ts, and scripts/hatch-scaffold.ts; configuration reads, validation, and settings registry behavior are centralized in scripts/lib/config-read.ts, scripts/lib/settings/registry.ts, and scripts/validate-config.ts. Repository plugin code is distinct from mutable operator state, including session records, knowledge, budget/cost logs, and generated Docker files.
Event-Driven Scheduling and Session Control
The system avoids model wakes unless filesystem prechecks determine work is due. Heartbeats, scheduled routines, monitors, and watchdog recovery form the control plane: scripts/heartbeat.ts, scripts/routine-monitor.sh, scripts/routines.ts, and scripts/lib/routines/. Prompt handling passes through a staged pipeline that applies context, channel command, pause, verification, and shutdown gates before model work: scripts/user-prompt-pipeline.ts and scripts/lib/prompt-stages/. tmux, cron/Monitor scheduling, and optional Docker provide the durable process boundary.
Learning, Knowledge, and Proposals
Session output and observations become durable evidence, then feed an operator-gated improvement loop. Key stages include session archival/digests (scripts/session-archive.ts, scripts/transcript-digest.ts), reflection evaluation (scripts/evaluate-session.ts, scripts/apply-reflection-actions.ts), and proposal lifecycle management (scripts/proposal.ts, scripts/lib/proposals/). Knowledge follows a raw-to-compiled model, with startup context bounded and searchable through scripts/startup-context.ts, scripts/knowledge-lint.ts, and scripts/search.ts. Proposal acceptance is the explicit boundary before runtime/self-modifying changes.
External Interfaces, Safety, and Observability
Claude Code is the host runtime and subscription-backed model provider. Optional integrations include Discord/Telegram channels, native push notifications, Claude Code Artifacts or a configured MCP artifact backend, and Claude remote control. Channel transport and trust controls are implemented in scripts/channel-hook.ts, scripts/channel-send.ts, and scripts/lib/channel-auth.ts. Safety is enforced at hook/tool boundaries through deny patterns, ask/pause gates, injection scanning, guest-session detection, and permission alerts: scripts/ask-gate.ts, scripts/pause-gate.ts, scripts/enforce-deny-patterns.ts. Cost/usage accounting and artifact reporting use scripts/cost-tracker.ts, scripts/report-export.ts, and scripts/lib/dashboard.ts.
Deployment and Extension Model
Docker setup renders a hardened baseline plus optional network-security overlay from plugins/claude-code-hermit/state-templates/docker/; preflight and template renderers are scripts/docker-preflight.ts and scripts/render-docker-templates.ts. Extension plugins independently contribute Claude skills, hooks, agents, settings, and sometimes domain runtimes. Notable code-backed extensions are Home Assistant’s Bun CLI/API layer (plugins/claude-code-homeassistant-hermit/src/cli.ts, src/ha-api.ts, src/policy.ts) and Laravel Forge’s PHP SDK wrapper (plugins/laravel-forge-hermit/php/forge.php, php/forge-operation.php). Root workflows and scripts/test-all.sh coordinate cross-plugin validation.
Main entry points: plugin.json Hermit plugin manifest · cli.ts Home Assistant extension · forge.php Laravel Forge extension
Components 21
Hermit Runtime
- Hermit plugin manifest · Installation entry point for the core plugin.
plugins/claude-code-hermit/.claude-plugin/plugin.json - Hatch setup · Creates and validates an installation-specific runtime.
- Config registry · Centralized configuration reads, validation, and settings.
- Operator state · Per-installation sessions, knowledge, budgets, and generated files.
- Resident session lifecycle · Starts, stops, pauses, and supervises Claude sessions.
- Durable process boundary · Keeps the resident runtime alive across operator sessions.
Control Plane
- Heartbeat prechecks · Avoids model wakes until filesystem checks find due work.
- Routines and monitors · Runs heartbeats, routines, monitors, and recovery checks.
- Watchdog recovery
- Prompt gate pipeline · Applies context, channel, pause, verification, and shutdown gates.
Learning Loop
- Session archive and digest · Turns session output into durable records and digests.
- Reflection evaluation · Evaluates sessions and derives follow-up actions.
- Proposal lifecycle · Acceptance gates runtime and self-modifying changes.
- Compiled knowledge · Bounds startup context while retaining searchable knowledge.
Interfaces & Safety
- Channel transport · Receives and sends trusted remote channel messages.
- Tool and prompt safety gates · Enforces deny, ask, pause, injection, and guest-session controls.
- Cost and artifact reporting · Tracks usage and exports reports or artifacts.
- Docker hardening · Renders hardened baseline and optional network overlays.
- Claude Code · Subscription-backed host for resident model sessions.
Extensions
- Home Assistant extension
plugins/claude-code-homeassistant-hermit/src/cli.ts - Laravel Forge extension
plugins/laravel-forge-hermit/php/forge.php
Connections 23
- Hermit plugin manifest → Hatch setup: installs
- Hatch setup → Config registry: creates and validates
- Hatch setup → Operator state: scaffolds
- Config registry → Resident session lifecycle: configures
- Resident session lifecycle → Durable process boundary: runs within
- Durable process boundary → Watchdog recovery: supervised by
- Watchdog recovery → Resident session lifecycle: recovers
- Routines and monitors → Heartbeat prechecks: schedules
- Heartbeat prechecks → Prompt gate pipeline: wakes only when due
- Prompt gate pipeline → Tool and prompt safety gates: enforces gates
- Channel transport → Prompt gate pipeline: delivers prompts
- Prompt gate pipeline → Claude Code: authorizes model work
- Claude Code → Session archive and digest: produces session output
- Session archive and digest → Operator state: stores evidence
- Session archive and digest → Reflection evaluation: feeds
- Reflection evaluation → Proposal lifecycle: creates improvements
- Proposal lifecycle → Resident session lifecycle: accepted changes apply to
- Session archive and digest → Compiled knowledge: contributes observations
- Compiled knowledge → Prompt gate pipeline: supplies startup context
- Claude Code → Cost and artifact reporting: usage tracked by
- Docker hardening → Durable process boundary: optional isolation
- Home Assistant extension → Claude Code: extends
- Laravel Forge extension → Claude Code: extends