Maintain and extend the .hermes mental-health domain infrastructure — plugin, hooks, commands, agents, skills, and skill bundles. Use when adding, modifying, or understanding the relationship between these layers.
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Maintain and extend the .hermes mental-health domain infrastructure — plugin, hooks, commands, agents, skills, and skill bundles. Use when adding, modifying, or understanding the relationship between these layers.
The .hermes/ directory for this project contains a full domain-specific agentic runtime: a Python plugin with clinical tools, shell hooks for patient scoping and privacy, slash commands for practitioner workflows, named agent configurations, 15 domain skills, and 5 skill bundles. This skill documents the architecture so future sessions can maintain and extend it.
Each agent YAML binds skills, hooks, and a system prompt:
name:assessment-reviewskills: [mental-health-core, mental-health-assessment-review, mental-health-patient-summary]
hooks:pre_tool:patient-scope-guardpost_response:output-privacy-reviewprompt:|
You are a DSM-5-TR assessment review specialist...
Skill Bundles → Skills + Instruction
Bundles group skills with a shared instruction prompt:
name:assessment-reviewskills: [mental-health-core, mental-health-assessment-review, mental-health-results]
instruction:|
You are a DSM-5-TR assessment review specialist.
Procedure:1.Loadthemeasurefromdata/shared/templates/json/<slug>.json.2.Loadthepatient'ssubmission.3.Computethescore(total,average,T-scoreasapplicable).4.Determinetheseverityband.5.RenderthecorrectchartperresultChart.6.Detectdata-qualityissues.7.GenerateclinicalinterpretationinEnglish.Alwayscitethespecificmeasure,thescore,andtheseverity.Markincompletedataas"unscorable"withanexplanation.
Makefile → Everything
The Makefile (HERMES_HOME=.hermes) wraps all layers as targets:
make hermes-chat — CLI with default skills
make hermes-gateway — Hermes API server on :8642 (Create With AI)
make hermes-gateway-curl-test — Verify gateway connectivity
make hermes-dashboard — Dashboard on :9120
make agent-assessment-review — named agent launch
make hooks-test — hook verification
make hermes-chat-bundle BUNDLE=safety-check — bundle launch
Makefile Bundle Mapping
The hermes-chat-bundle target uses nested $(if $(filter ...)) to map bundle names to skill lists. When adding a new bundle:
Create skill-bundles/<name>.yaml
Add the mapping to the hermes-chat-bundle target's --skills argument
Add to help text
HERMES_BUNDLE ?= mental-health
hermes-chat-bundle:# Validates bundle file exists, then launches hermes with mapped skills
Create skills/mental-health/<name>/SKILL.md with YAML frontmatter + markdown body
If it has references, create skills/mental-health/<name>/references/<topic>.md
Add to the mental-health bundle in skill-bundles/mental-health.yaml
Add to any relevant sub-bundles (assessment-review, patient-session, etc.)
If a Makefile agent target should load it, update the agent target
Adding a New Agent
Create agents/<name>.yaml with name, skills, hooks, prompt
Add make agent-<name> target to Makefile in the Hermes Agents section
Add help line for the target
Adding a New Hook
Create hooks/<name>.sh (must be executable: chmod +x)
Reference it from agent YAML files (hooks.pre_tool or hooks.post_response)
Add test cases to make hooks-test
Hermes Gateway API Server (Create With AI)
The Next.js "Create With AI" feature (app/api/assessments/generate/route.ts) calls the Hermes gateway's REST API at 127.0.0.1:8642. The app never calls OpenRouter (or any model provider) directly — the Hermes agent gateway is the single proxy for all AI model calls. The gateway must be started with HERMES_HOME pointing to the project's .hermes/ so it loads the project-scoped model config (provider + model, e.g. openrouter → deepseek/deepseek-v4-pro), which it uses internally when proxying requests.
Starting the gateway
# Via Makefile (preferred — auto-kills stale process, sets HERMES_HOME)
make hermes-gateway
# Or manually
HERMES_HOME=/Users/josoroma/projects/hermes-mental-health/.hermes \
API_SERVER_ENABLED=true \
API_SERVER_KEY=change-me-local-dev \
hermes gateway
Override key or port: make hermes-gateway HERMES_GATEWAY_KEY=my-key HERMES_GATEWAY_PORT=8643.
The API_SERVER_KEY must match the value in the Next.js .env file (API_SERVER_KEY=change-me-local-dev).
Verifying the gateway is up
# Makefile target — checks connectivity, sends test run, prints result
make hermes-gateway-curl-test
# Quick manual connectivity check (expect anything but "connection refused")
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8642/v1/runs
# Full test — create a run (expect a run_id in response)
curl -s http://127.0.0.1:8642/v1/runs \
-H "Authorization: Bearer change-me-local-dev" \
-H "Content-Type: application/json" \
-d '{"input": "/goal test", "instructions": "You are a test."}'
API flow (what route.ts does)
POST /v1/runs with {"input": "...", "instructions": "..."} → returns {"run_id": "...", "status": "started"}
Poll GET /v1/runs/{run_id} every 3s until status: "completed" → output field contains the result
Status values: started → running → completed | failed | error
Fields: input (not prompt), instructions (system prompt for the run).
Detailed curl recipes, polling scripts, and response shapes: references/hermes-gateway-api.md.
The HERMES_API_SERVER_URL points to the Hermes agent gateway — all model calls go through this proxy. There is no direct OpenRouter (or any other provider) endpoint in the app's env vars.
Common Pitfalls
Gateway must use project HERMES_HOME, not global config. Starting hermes gateway without HERMES_HOME set picks up ~/.hermes/config.yaml, which may have a different model provider (e.g., a local GGUF on :8080). The gateway will accept API requests but fail all runs with Connection error. because the model isn't reachable. Use make hermes-gateway (preferred) or HERMES_HOME=<project>/.hermes hermes gateway. The Makefile target handles port conflicts and sets the correct env vars automatically.
Skills don't auto-discover from the mental-health/ category. Hermes skill loading scans skills/ recursively, but if a new skill doesn't appear in skills_list, run hermes update or restart the session. The session's skill loader is cached at startup.
Bundle YAML must list skill names exactly as they appear in manifest.yaml. A mismatch means the skill silently won't load when the bundle is used.
Hook scripts must be executable. The hooks-test Makefile target tests them, but agents will silently skip non-executable hooks.
The hermes-chat-bundle Makefile target has a fragile nested $(if) chain. When adding a new bundle, test with make -n hermes-chat-bundle BUNDLE=<name> to verify the skill list expands correctly before launching.
Patient scope guard runs on every tool call. If you add a tool that legitimately needs cross-patient context (e.g., aggregate reporting), it will be blocked. Such tools should run outside the patient scope or the guard should be configured with exceptions.
All patient data is synthetic. Never introduce real PHI into seeds, templates, or session context. The output-privacy-review.sh hook catches common PHI patterns but is a heuristic, not a guarantee.
execute_code can corrupt files with line-number prefixes. When using execute_code with read_file + write_file, written files may embed NNNN| prefixes from the read output format. Always verify with sed -n '1,5p' <file> after programmatic writes. Fix: python3 -c "import re; f=open('file'); c=f.read(); f.close(); open('file','w').write(re.sub(r'^\\d{1,4}\\\\|', '', c, flags=re.M))". This has happened twice on SPECS.md — prefer terminal-based python heredocs over execute_code for file mutations.
Skill bundle instructions must be in English. All .hermes/skill-bundles/*.yaml metadata, descriptions, and instruction prompts must use English. The practitioner operates in English and the clinical domain uses English — Spanish content in bundle files creates drift and confusion for future sessions. Verify with: grep -rilE 'Eres|español|especialista|evaluación' .hermes/skill-bundles/ (should return empty).
Verification Checklist
ls .hermes/plugins/hermes-mental-health/ — 4 files (plugin.yaml, init.py, tools.py, schemas.py)
ls .hermes/hooks/ — 2 executable scripts
ls .hermes/commands/ — mental-health.md
ls .hermes/agents/ — 3 YAML files (assessment-review, patient-intake, patient-progress-weekly)
make help — shows agents, hooks, and bundles sections
docs/HERMES-MENTAL-HEALTH.md — Complete Next.js → agent mapping with prompt templates (hand-written, not generated)
Reference
docs/HERMES-MENTAL-HEALTH.md — Cross-reference: maps every Next.js app page and feature to Hermes agents, bundles, and ready-to-use API prompts. Priority AI buttons. Implementation code.