@promptster/setup
v0.1.0
Published
npx enrollment installer — wires Claude Code telemetry + hooks into ~/.claude/settings.json
Readme
@promptster/setup
One command, no binary, no daemon, no login:
npx @promptster/setup --token <your-token>It edits exactly one file — ~/.claude/settings.json — and writes one script,
~/.promptster/spool.mjs. Nothing else on the machine is touched.
--print dry run: print the plan, write nothing
--tier a telemetry only, no hooks
--uninstall put settings.json back the way it wasWhat it writes
Tier A — telemetry. CLAUDE_CODE_ENABLE_TELEMETRY, the OTLP exporter/protocol/
endpoint/headers pair, and OTEL_LOG_TOOL_DETAILS=1.
Tier B — hooks. One command hook per lifecycle event (SessionStart,
UserPromptSubmit, PreToolUse, PostToolUse, Stop, SubagentStop,
PreCompact, SessionEnd) pointing at the spool script.
OTEL_LOG_USER_PROMPTS and OTEL_LOG_ASSISTANT_RESPONSES are never written, so
prompt and response text stays off. OTEL_LOG_RAW_API_BODIES is never written
under any flag — there is no option that turns it on.
The guards, and why each exists
| Guard | Behaviour |
| --- | --- |
| Diff first | The plan is printed before any write, on every path. --print is that render with the write removed. |
| Append, never replace | Our hook group is pushed onto the end of an existing event array. An existing statusLine is not touched at all. Silently deleting someone's audit hook is unrecoverable and invisible; nothing here can do it. |
| Idempotent | A second and third consecutive run produce an empty diff and write zero bytes. |
| No clobbering env | An env key set to a value this installer did not write stops the run (exit 2). Ownership is value-matched, so a key you edited after enrolling is yours again. |
| disableAllHooks preflight | Checked across managed policy, user, and project settings. If hooks are off machine-wide we do not write dead hook entries; we say tier B will not run and exit 3. |
| Foreign OTLP endpoint | Claude Code supports one endpoint. If it is already someone else's, we print a collector fan-out config and exit 4 without writing. |
| Byte-for-byte uninstall | The pre-install file is snapshotted verbatim. --uninstall restores it exactly — but only if settings.json is unchanged since we wrote it. If you edited it, we remove only our own entries and say so, rather than silently reverting your edit. |
Exit codes: 0 ok, 1 usage, 2 env conflict, 3 hooks disabled, 4 foreign
endpoint, 5 unparseable settings.json.
Development
pnpm --filter @promptster/setup test
pnpm --filter @promptster/setup exec tsc --noEmitThe --print output and the disclosure text are pinned by golden files in
src/__tests__/__fixtures__/. The disclosure is the user-facing egress contract:
if the wire behaviour changes, that fixture has to change in the same commit,
which is exactly the review moment we want.
