/promptbook:setupfrom promptbook
Set up Promptbook — connect your account to start tracking builds. Use when the user wants to enable session analytics on promptbook.gg. Trigger with "/setup" or "set up promptbook".
Ships in promptbook. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Connect a Promptbook account using the device-code OAuth flow. After consent, the plugin tracks session metrics (prompts, tokens, build time, lines changed) and publishes shareable build cards on promptbook.gg.
What IS sent to promptbook.gg: session ID, project name, model, timestamps, prompt count, token counts, build time, lines changed, language, file extension counts, and tool usage counts.
What is NEVER sent: source code, prompt content, file contents, file paths, or working directory.
To generate a title and summary for each build, the plugin calls Claude Haiku via the user's own Claude credentials — this data goes to Anthropic (same as normal Claude Code usage), never to Promptbook.
The plugin stays inactive until setup writes consent into ~/.promptbook/config.json. Continuing with setup means the user consents to this data collection. After each session ends, a short background process may continue briefly to submit stats and generate the title/summary.
Run all commands via Bash — the user just waits for the browser sign-in.
curl -sL -X POST "https://promptbook.gg/api/auth/setup-session"
Parse the JSON response to extract three values: token, device_code, and setup_url.
Use the setup_url value from step 1:
open "<setup_url value>" # macOS
xdg-open "<setup_url value>" # Linux
Tell the user: "Opening promptbook.gg — sign in or create an account to continue." If the browser cannot open, show the URL for manual access.
Check every 2 seconds using the token from step 1:
curl -sL "https://promptbook.gg/api/auth/setup-session/<token value>/status"
Parse the JSON and check whether status equals "authorized". Use a unique variable name like poll_result or auth_status (do NOT use a variable named status). Timeout after 5 minutes.
curl -sL -X POST "https://promptbook.gg/api/auth/setup-session/exchange" \
-H "Content-Type: application/json" \
-d "{\"device_code\": \"<device_code value>\"}"
Parse the JSON response to extract api_key.
Write to ~/.promptbook/config.json — the canonical config location shared by both plugin and bash installs:
mkdir -p "$HOME/.promptbook"
cat > "$HOME/.promptbook/config.json" << 'JSONEOF'
{
"api_key": "<api_key from step 4>",
"api_url": "https://promptbook.gg",
"auto_summary": true,
"telemetry_consent": true
}
JSONEOF
chmod 600 "$HOME/.promptbook/config.json"
The chmod 600 restricts config access to the owning user only — the file contains the API key.
curl -sL -X POST "https://promptbook.gg/api/auth/verify-setup" \
-H "Authorization: Bearer <api_key value>"
Tell the user:
/setup again anytime to reconnect or switch accounts."Ask the user: "Want me to scan your Claude Code history for past sessions? I can find builds from the last 90 days and upload them to your profile."
If yes, find the bundled backfill script:
find ~/.claude -path "*/promptbook/scripts/backfill-history.js" -type f 2>/dev/null | head -1
If it does not exist, stop and tell the user the plugin install looks incomplete. Do not download code from the network.
Count matching session files first:
find "$HOME/.claude/projects" -name "*.jsonl" -type f 2>/dev/null | wc -l
Then start in the background:
nohup node <path-to-backfill-history.js> \
--days 90 \
--generate-summaries \
> "$HOME/.promptbook/backfill-history.log" 2>&1 < /dev/null &
Tell the user: "Found session files. History import started in the background. See status at https://promptbook.gg/setup/history"
On success, display:
/setup againUser: /setup
Agent: Creating setup session... Opening promptbook.gg — sign in or create an account.
Waiting for authorization... Authorized! Saving config...
You're all set! Tracking starts on your next Claude Code session.
Want me to scan your history for past sessions?
What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
Other plugins' skills for the same job
npx claudepluginhub flight505/skill-forge --plugin promptbook