run-platform
Skill25 starsChanged 5 months agoMITView on GitHub
Spin up a local hexgate platform instance (FastAPI platform-api + React dashboard + MCP server, optionally the full OTLP pipeline) — check prerequisites first (uv, pnpm, Docker, Go, free ports), start the servers in the background, and hand back the dashboard URL, the first-boot admin email and password, and register the local MCP server with Claude Code (`claude mcp add`) so the user only opens a new session and authenticates. Use when asked to run, start, spin up, or demo the platform/dashboard/MCP server locally, or to get a login for a local instance; "without MCP" or "dashboard only" skips the MCP server. Local dev machine only, not staging or prod (those are deploy stacks, see platform/DEPLOY.md).
- Reads credentials
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- hexgate/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- hexgate/CLAUDE.mdCLAUDE.md
- film-demoSkill
- integration-testsSkill
- pr-descriptionSkill
- write-adrSkill
- write-policySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 4 are distinctive, and 14 are 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.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 35
Add --no-mcp (to either) when the user opted out of the MCP server.
- Distinctive: line 46
Pick the mode: Default to light unless the user wants audit events, agents talking to the platform, or integration tests.
- Very specific: line 58
Not running on Linux, or not installed anywhere: give the user the hint the preflight printed.
- Very specific: line 89
Start the API with make platform-api-pg, not platform-api (keys minted on SQLite get a 401 from the collector), and wait for its /health: …
- Very specific: line 96
Start make collector-run and make enricher-run as background commands, appending to $LOGDIR/collector.log and $LOGDIR/enricher.log.
- Very specific: line 98
Start the dashboard and make mcp-run as in light mode.
- Very specific: line 106
Wait until the API answers curl -sf localhost:8000/health and .claude/skills/run-platform/instance.sh dash prints this checkout's dashboard …
- Very specific: line 117
If it never prints up, read mcp.log: an address-in-use error means another MCP server holds :8080 (see the preflight).
- Very specific: line 153
Check it works (expect 204):
- Distinctive: line 163
If the curl check itself fails, the block is stale (the password was rotated or reset since, or a different database is running): treat it …
- Distinctive: line 168
use the password they saved earlier.
- Very specific: line 178
Stop only the API, not the whole instance: kill <pid> with the pid who printed, and wait until curl -sf -m 2 localhost:8000/health fails.
- Very specific: line 250
hexgate shows as failed in
/mcp: if :8000, :5173 and :8080 are free, the session that started the servers was quit, which stopped them. - Very specific: line 255
"Safari can't connect to the server localhost:5173": after Authenticate: the API's HEXGATE_DASHBOARD_URL has no dashboard behind it.
- Very specific: line 284
Leave out the OTLP pipeline line in light mode, and the MCP and Next lines when the user opted out of the MCP server.
- Very specific: line 286
When the registration was there before this session started (step 5), replace open a NEW terminal: claude → /mcp → hexgate → Authenticate …
- Very specific: line 290
Add (keep this session open, it owns the servers) to the Next line only when this run started any server (rather than reusing ones already …
- Distinctive: line 293
Don't mention stale FIRST-BOOT blocks unless the password line depends on them.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
Run the hexgate platform locally
Scope: your own machine only. This skill runs dev servers on localhost
against local SQLite or Docker databases. It does not start, stop, or log into
staging or prod. Those are deploy stacks (make platform-up STAGE=staging|prod,
see platform/DEPLOY.md). If the user asks for staging or prod, point them
there and don't run anything from this skill against them.
Goal: a running instance the user can log into and connect Claude Code to. End with the URL, email, password and the MCP server registered in Claude Code, or with exactly what is missing.
The MCP server is part of the platform, so start it every time. Skip it (and its port, step and report line) only when the user asks for the platform "without MCP" or "dashboard only".
Works on macOS and Linux. The paths and make targets below are relative to
the repo root, and each command runs in a fresh shell, so start every
command with this line (it also sets the log directory used from step 3 on):
cd "$(git rev-parse --show-toplevel)" && LOGDIR="/tmp/hexgate-$(basename "$PWD")" && mkdir -p "$LOGDIR"1. Preflight
.claude/skills/run-platform/preflight.sh # light mode
.claude/skills/run-platform/preflight.sh --full # full pipelineAdd --no-mcp (to either) when the user opted out of the MCP server.
- Any
MISSline: stop and give the user the install hint the script printed. 8000 busy: an API may already be running, but/healthlooks the same whatever database it uses, so check with.claude/skills/run-platform/instance.sh whobefore reusing it. Reuse it only when its checkout is this one and its target fits the mode you pick below:make platform-apifor light,make platform-api-pg(or a PostgresDATABASE_URL) for full. A light-mode API under a full pipeline looks healthy, but the collector rejects every key it mints with 401.- This checkout, wrong mode:
kill <pid>with the pidwhoprinted, wait untilcurl -sf -m 2 localhost:8000/healthfails, then start the right target in step 3. - Another checkout: ask the user before stopping it; it may be in use.
not a hexgate API on :8000: tell the user what holds the port.
- This checkout, wrong mode:
5173 busy: fine if it's another checkout's dashboard; Vite starts this one on the next free port, and step 3 finds it.8080 busy: an MCP server may already be running. Check its checkout with.claude/skills/run-platform/instance.sh owner 8080: reuse it if that prints this checkout, otherwise ask the user before stopping it;make mcp-runwould fail on the taken port.4317/4318 busyin full mode: a collector is already running.make collector-runwould fail on it, so find out whose it is before starting yours.
Pick the mode. Default to light unless the user wants audit events, agents talking to the platform, or integration tests.
| Mode | Runs | Needs |
| light | platform-api (SQLite) + dashboard + mcp-run | uv, pnpm, claude CLI (for the MCP server) |
| full | + Postgres, Redpanda, ClickHouse, collector, enricher (make demo-platform prints the recipe) | + Docker, Go |
No Docker? Explain the options to the user instead of failing:
- Light mode needs no Docker. The API uses SQLite and the dashboard is plain Vite. You can log in, manage agents and policies, and mint tokens. But there is no audit trail, so agent decisions don't show up on the audit page.
- Full mode needs Docker, because Postgres, Redpanda and ClickHouse run as containers. The preflight's hint differs between macOS (Docker Desktop) and Linux (Docker Engine,
systemctl, thedockergroup).- Installed but not running, on macOS: run
open -a Dockeryourself, then rerun the preflight until it printsdocker (running)(don't polldocker infodirectly: it hangs while Docker is starting). Runopen -a Dockeronce only. If Docker isn't running after about 2 minutes, stop and ask the user to check the Docker Desktop window: a first launch waits for them to accept the terms. - Not running on Linux, or not installed anywhere: give the user the hint the preflight printed. Never do these yourself: starting it on Linux needs
sudo, and installing needs the user's approval. - Then rerun the preflight.
- Installed but not running, on macOS: run
2. Install (first time, idempotent)
UV_PYTHON=3.13 make platform-api-install
make dashboard-installUV_PYTHON=3.13 is needed because biscuit-python fails to build on Python 3.14.
3. Start (each as a background command, logs to files)
Logs go to $LOGDIR (set by the line at the top), one fixed directory per
checkout, so a later command or a later session can find them again. Always
append (>>): a restart must not erase the one-time password block.
Light mode:
UV_PYTHON=3.13 make platform-api >> "$LOGDIR/api.log" 2>&1 # :8000
make dashboard >> "$LOGDIR/dash.log" 2>&1 # :5173
make mcp-run >> "$LOGDIR/mcp.log" 2>&1 # :8080Full mode, in this order:
- Bring up the infrastructure first, in one foreground command, so the two
background targets below don't race to create the same containers:
make postgres-init redpanda-topics clickhouse-migrate.clickhouse-migratealso brings an old ClickHouse schema up to date; the enricher exits on a stale one. - Start the API with
make platform-api-pg, notplatform-api(keys minted on SQLite get a 401 from the collector), and wait for its/health: the collector needsplatform/api/data/hexgate.pub, which the API writes on its first boot. - Build the collector, every time (the binary is gitignored, so an old one
would silently stay):
cd platform/collector && go build -o hexgate-collector ..collector-runruns the binary and doesn't build it. - Start
make collector-runandmake enricher-runas background commands, appending to$LOGDIR/collector.logand$LOGDIR/enricher.log. - Start the dashboard and
make mcp-runas in light mode.
The MCP server's defaults already fit this setup, so export nothing:
HEXGATE_MCP_API_URL is http://localhost:8000 and HEXGATE_MCP_RESOURCE_URL
is http://localhost:8080/mcp. It doesn't read platform/api/.env. So if the
API runs with a non-default HEXGATE_PUBLIC_URL, export the same value to
make mcp-run, or every token gets refused for its issuer.
Wait until the API answers curl -sf localhost:8000/health and
.claude/skills/run-platform/instance.sh dash prints this checkout's dashboard
URL. Don't probe localhost:5173 directly: when another checkout's dashboard
holds it, Vite quietly moves this one to the next port. Watch api.log for a
Traceback while you wait. A CSS @import warning in dash.log is harmless.
Then wait for the MCP server's health check, which names the service, so
another app on :8080 doesn't pass for it (on a fresh checkout uv run first
builds the MCP server's venv, so this can take a while):
for _ in $(seq 1 60); do curl -sf -m 2 localhost:8080/health | grep -q hexgate-mcp && echo up && break; sleep 1; doneIf it never prints up, read mcp.log: an address-in-use error means another
MCP server holds :8080 (see the preflight).
The OAuth login ends on a consent page on the API's HEXGATE_DASHBOARD_URL,
and the consent form is refused unless its origin matches that URL exactly.
The API reads it from the shell first, then platform/api/.env, else
http://localhost:5173. Resolve it the same way:
url=${HEXGATE_DASHBOARD_URL:-}
[ -z "$url" ] && [ -f platform/api/.env ] && url=$(sed -n 's/^HEXGATE_DASHBOARD_URL=//p' platform/api/.env | tail -1)
echo "${url:-http://localhost:5173}"Compare it with the URL instance.sh dash printed:
- The same: nothing more to do.
- Different: usually Vite moved off a 5173 that another checkout holds, or
.envsets another host such as127.0.0.1. Restart the API withHEXGATE_DASHBOARD_URL=<the instance.sh dash URL>(it reads its settings only at startup). Otherwise consent opens a dashboard that isn't this one, or the consent form gets a 403.
In full mode the pipeline must be up too, or the audit page stays empty while everything else looks fine. Before reporting, check that:
- the collector answers:
curl -s -o /dev/null localhost:4318 && echo up; - the collector and enricher background tasks are still running, and their logs
have no
Tracebackor error exit. On a schema error, runmake clickhouse-migrateand start the enricher again.
4. Credentials
On first boot against an empty database, the API seeds admin@hexgate.dev
and prints its password once to stderr:
grep -A3 "FIRST-BOOT" "$LOGDIR/api.log" | tail -4 # the newest block, if there are severalCheck it works (expect 204):
curl -s -o /dev/null -w "%{http_code}\n" -X POST localhost:8000/v1/auth/cookie/login \
-d "username=admin@hexgate.dev&password=<password>"A dashboard login answering 400 LOGIN_BAD_CREDENTIALS while the curl check
gives 204 means the password didn't paste exactly: a trailing space, or 0
mistaken for O. Give it to the user in a code block.
If the curl check itself fails, the block is stale (the password was rotated or reset since, or a different database is running): treat it as no block.
No FIRST-BOOT block means the database was already seeded, and the password can't be printed again. Offer these options and let the user choose:
- use the password they saved earlier;
- reset the password, which keeps the database. This needs the API's stderr, so
it only works on an API you started. If it was started elsewhere, restart it
with its log going to a file first, from the same checkout and with the same
target, or it opens a different database: the reset and login then succeed,
but on the wrong one. Find its checkout, its target, and any exported
DATABASE_URL:
Stop only the API, not the whole instance:.claude/skills/run-platform/instance.sh whokill <pid>with the pidwhoprinted, and wait untilcurl -sf -m 2 localhost:8000/healthfails. Then restart from that checkout with that target, and the sameDATABASE_URLif one was exported. If the checkout or the target is missing, ask the user. When it is another checkout, keep this checkout's$LOGDIRfor that restart (don't rerun the top line there), so the token lookup below reads the right log; a laterinstance.sh stopmust then run from that checkout. Either database survives a restart. If bothRESEND_API_KEYandHEXGATE_EMAIL_FROMare set (in the shell orplatform/api/.env), the email is really sent instead of printed, so no token reaches the log:
Pick a password of letters, digits andn=$(wc -l < "$LOGDIR/api.log") # only read what this request logs curl -s -w ' %{http_code}\n' -X POST localhost:8000/v1/auth/forgot-password \ -H 'content-type: application/json' -d '{"email":"admin@hexgate.dev"}' # 202 TOKEN=$(tail -n +$((n + 1)) "$LOGDIR/api.log" | grep -o 'reset-password/[^ ]*' | tail -1 | cut -d/ -f2) curl -s -w ' %{http_code}\n' -X POST localhost:8000/v1/auth/reset-password \ -H 'content-type: application/json' \ -d "{\"token\":\"$TOKEN\",\"password\":\"<letters-digits-dashes>\"}" # 200-: the login check sends a form body, so+,&or%would make it fail even though the reset worked. The token expires after an hour. Then run the login check above with the new password; - start from a fresh database. For SQLite, stop the API and move
platform/api/hexgate.dbaside (don't delete it). For Postgres, runmake postgres-reset, which wipes the one Postgres volume every checkout shares, so ask first; then restart the API, which creates the tables and seeds (printing a new block) only at startup; - light mode only: run in a fresh git worktree, which gets its own SQLite database. Full mode gets nothing fresh from a new worktree, because all checkouts share the same Postgres.
5. Connect Claude Code
Skip this when the user opted out of the MCP server.
Register the server yourself; it is a shell command that writes
~/.claude.json. Check first:
claude mcp get hexgate- It shows
http://localhost:8080/mcp: already registered, add nothing. - It says there is no server named
hexgate: register it.claude mcp add -s user --transport http hexgate http://localhost:8080/mcp - It shows another URL: ask the user before replacing it, since it may be
their connection to another instance. Remove it at the scope its
Scope:line names (claude mcp remove hexgate -s <user|local|project>), then run the add above: a local or project entry left in place would shadow the new user one.
instance.sh stop removes the user-scope registration again once :8080 is free.
Remember whether you added it or found it; the report says which.
Two things only the user can do, in their own session:
- Open a new Claude Code session in another terminal, and keep this one open: the servers are this session's background commands, so quitting it stops them. A session reads its MCP servers when it starts, so one that started before the registration doesn't see the server. If the registration was already there before this session started, this session sees it already, so skip to 2 here.
- In that session, open
/mcp, choosehexgate, then Authenticate. The browser opens the dashboard by itself, nothing to paste: log in with the step 4 credentials, then approve the consent page. Then a first prompt: "List my Hexgate projects".
HEXGATE_OAUTH_ALLOW_INSECURE_CLIENT_IDS is not needed for Claude Code.
Its client id is https://claude.ai/oauth/claude-code-client-metadata, an https
URL the API fetches as usual. Set it, on the API, only for a client whose
client id is an http://localhost URL, such as a metadata document you serve
yourself. The API refuses to start with it when its public or dashboard URL is
not local.
Failure modes:
- "No Hexgate MCP server connected" (or the session has no hexgate tools): the session started before the server was registered. Open a new session in another terminal.
- hexgate shows as failed in
/mcp: if :8000, :5173 and :8080 are free, the session that started the servers was quit, which stopped them; run/run-platformagain and keep that session open. If they are up, the session loaded hexgate before :8080 answered; choose Reconnect, then Authenticate. - "Safari can't connect to the server localhost:5173" after Authenticate:
the API's
HEXGATE_DASHBOARD_URLhas no dashboard behind it. Either the dashboard isn't running (start it, step 3), or it runs on another port (set the variable as in step 3 and restart the API). Then authenticate again. 401onPOST /mcpinmcp.log: this is normal before login. That's how the server tells the client to authenticate. It's only a problem if it keeps happening after the consent page has been approved.
6. Report
Reply with exactly this block, filled in, and nothing else: no sentence before or after it.
Hexgate platform · <light|full> mode · logs <dir>
Dashboard http://localhost:5173 admin@hexgate.dev / <password or "unchanged">
API http://localhost:8000 (<SQLite|Postgres>)
OTLP pipeline collector :4317/:4318 · enricher running ← full mode only
MCP http://localhost:8080/mcp registered as `hexgate` (<added|found>)
Next open a NEW terminal: claude → /mcp → hexgate → Authenticate → "List my Hexgate projects"
Stop .claude/skills/run-platform/instance.sh stop
Notes <one line per anomaly, e.g. "enricher restarted once (Postgres init deadlock)">; omit the line when there is noneRules:
- Name the mode once, in the header line.
Dashboardis the URLinstance.sh dashprinted. The password is the one the login check accepted, orunchangedwhen the database was already seeded and the user keeps their saved one.- Leave out the
OTLP pipelineline in light mode, and theMCPandNextlines when the user opted out of the MCP server. - When the registration was there before this session started (step 5),
replace
open a NEW terminal: claude → /mcp → hexgate → Authenticatewith/mcp → hexgate → Reconnect → Authenticate: this session loaded hexgate before :8080 answered, so/mcpshows it as failed until reconnected. - Add
(keep this session open, it owns the servers)to theNextline only when this run started any server (rather than reusing ones already running): quitting this session stops them. - Don't mention stale FIRST-BOOT blocks unless the password line depends on them.
The password is a local dev credential, so printing it in chat is fine. Never do this against a staging or prod stack.
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
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.

