Skip to content

Commit a052f80

Browse files
onlycastleclaude
andauthored
feat(plugin): first-run onboarding + sequential Phase 2 execution (#172)
* fix(plugin): run Phase 2 skills sequentially to eliminate rate limits Two-batch approach (3+4) still triggered rate limit failures on Claude Max. Switch to fully sequential execution — each of the 7 Phase 2 skills runs one at a time with the previous completing before the next starts. Adds ~5 min to pipeline wall time but eliminates all concurrent Sonnet burst issues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(plugin): add user preferences module Persistent prefs stored in ~/.betterprompt/prefs.json, separate from the transient plugin-state.json. Provides readPrefs/writePrefs (merge semantics) and isFirstRun() for onboarding detection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(plugin): add first-run onboarding skill /bp-setup wizard: verifies installation via scan_sessions, optionally adds command reference to CLAUDE.md, one-time GitHub star prompt, and points users toward their first /bp-analyze run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(plugin): integrate first-run detection into session hooks SessionStart hook now checks isFirstRun() before pending-analysis, injecting /bp-setup context for new users. Priority order: skip compact → first-run → pending analysis → no-op. DI via deps object keeps the handler fully testable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore(plugin): rebuild dist with onboarding changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add first-run onboarding to plugin docs and README README: rewrite install flow with terminal commands, add /bp-setup step. PLUGIN.md: register prefs.ts, bp-setup skill, session-start priority. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: fix stale "2 batches" header in LLM_FLOW.md Phase 2 section Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add prefs.json cleanup step to plugin testing checklist Without this step, a leftover welcomeCompleted flag silently skips the first-run onboarding flow during testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c4793f2 commit a052f80

21 files changed

Lines changed: 532 additions & 117 deletions

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ See `docs/agent/DEPLOYMENT.md` for the current self-hosted runtime model and def
116116
> 5. Delete `~/.claude/plugins/marketplaces/betterprompt/`
117117
> 6. Clear any project-level `settings.local.json` with betterprompt entries
118118
> 7. Check for and remove any plugin state databases (`bp-results*`, `bp-stage*`)
119-
> 8. Validate all JSON files after edits (trailing comma issues are common)
119+
> 8. Delete `~/.betterprompt/prefs.json` to reset first-run onboarding state
120+
> 9. Validate all JSON files after edits (trailing comma issues are common)
120121
121122
## Documentation
122123

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,24 @@ The recommended way to use BetterPrompt. Zero configuration required.
2929

3030
### 1. Install the plugin
3131

32-
In any Claude Code session, run:
32+
In your terminal:
3333

34-
```
35-
/plugin marketplace add onlycastle/BetterPrompt
36-
/plugin install betterprompt@betterprompt
34+
```bash
35+
claude plugin marketplace add onlycastle/BetterPrompt
36+
claude plugin install betterprompt@betterprompt
3737
```
3838

3939
That's it. The MCP server, analysis skills, and post-session hooks are registered automatically.
4040

41-
If `autoAnalyze` is enabled, BetterPrompt can queue an analysis at session end and inject startup context in the next Claude Code session so the queued run resumes automatically.
41+
### 2. First-time setup
4242

43-
### 2. Run your analysis
43+
On your first Claude Code session after installation, the `/bp-setup` wizard runs automatically. It verifies your installation, optionally adds a command reference to your CLAUDE.md, and points you toward your first analysis. You can also invoke it manually anytime:
44+
45+
```
46+
/bp-setup
47+
```
48+
49+
### 3. Run your analysis
4450

4551
In any Claude Code session, run:
4652

@@ -50,6 +56,8 @@ In any Claude Code session, run:
5056

5157
The plugin orchestrates the full pipeline -- scan sessions, extract data, analyze each domain, classify your type, and serve a report at `http://localhost:3456`.
5258

59+
If `autoAnalyze` is enabled, BetterPrompt can queue an analysis at session end and inject startup context in the next Claude Code session so the queued run resumes automatically.
60+
5361
### Available Commands
5462

5563
| Command | Description |
@@ -63,10 +71,10 @@ The plugin orchestrates the full pipeline -- scan sessions, extract data, analyz
6371

6472
### Uninstalling
6573

66-
In any Claude Code session, run:
74+
In your terminal:
6775

68-
```
69-
/plugin uninstall betterprompt@betterprompt
76+
```bash
77+
claude plugin uninstall betterprompt@betterprompt
7078
```
7179

7280
To also remove local analysis data (results, reports, caches):

docs/agent/PLUGIN.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Claude Code plugin at `packages/plugin/`. MCP server + queued auto-analysis hook
2828
| `lib/report-template.ts` | Standalone HTML report generator |
2929
| `lib/evaluation-assembler.ts` | Assembles canonical run from results DB |
3030
| `lib/api-client.ts` | HTTP client, `fetchUserSummary()`, `verifyAuth()` |
31+
| `lib/prefs.ts` | User preferences (`~/.betterprompt/prefs.json`), first-run detection |
3132
| `lib/debounce.ts` | Debounce rules, state file read/write |
3233
| `lib/background-analyzer.ts` | Deprecated cutover stub kept only to fail loudly if invoked |
3334
| `lib/core/session-scanner.ts` | Claude Code JSONL parsing and local data-dir helpers |
@@ -46,8 +47,10 @@ Claude Code plugin at `packages/plugin/`. MCP server + queued auto-analysis hook
4647
| `lib/scanner/sources/sqlite-loader.ts` | Shared SQLite loader for Cursor sources |
4748
| `lib/scanner/tool-mapping.ts` | Tool name normalization across sources |
4849
| `hooks/post-session-handler.ts` | `SessionEnd` hook, <1.5s, queues the next local analysis run |
49-
| `hooks/session-start-handler.ts` | `SessionStart` hook, injects queued `/bp-analyze` context |
50+
| `hooks/session-start-handler.ts` | `SessionStart` hook, first-run detection + queued `/bp-analyze` context |
5051
| `hooks/hooks.json` | Hook registration (`SessionStart` + `SessionEnd`) |
52+
| `skills/bp-setup/SKILL.md` | Guided onboarding wizard skill |
53+
| `skills/bp-analyze/SKILL.md` | Full analysis pipeline orchestrator skill |
5154
| `.claude-plugin/plugin.json` | Plugin metadata + config schema |
5255
| `.mcp.json` | MCP server config (stdio transport) |
5356

@@ -112,6 +115,7 @@ Route implementation: `app/api/analysis/user/summary/route.ts`
112115
| `~/.betterprompt/current-run-id.txt` | Text | Active analysis run ID for cross-tool coordination |
113116
| `~/.betterprompt/scan-cache/` | JSON | Parsed session cache from multi-source scanner |
114117
| `~/.betterprompt/reports/` | HTML | Generated reports (`report-{timestamp}.html`, `latest.html`) |
118+
| `~/.betterprompt/prefs.json` | JSON | User preferences: `welcomeCompleted`, `welcomeVersion`, `starAsked` |
115119
| `~/.betterprompt/plugin-state.json` | JSON | Lifecycle state: `idle/pending/running/complete/failed` + timestamps |
116120
| `~/.betterprompt/plugin-errors.log` | Text | Timestamped hook/deprecation errors |
117121

@@ -186,6 +190,7 @@ Discovery for Claude Code data dirs uses a waterfall: default `~/.claude/` path,
186190
- `node ./dist/hooks/session-start-handler.js`
187191
- `node ./dist/hooks/post-session-handler.js`
188192
- `SessionEnd` queues work; `SessionStart` injects context so Claude Code consumes the queued run in-band
193+
- `SessionStart` priority: (1) skip `compact`, (2) first-run → `/bp-setup`, (3) pending analysis → `/bp-analyze`, (4) no-op
189194

190195
## Build
191196

0 commit comments

Comments
 (0)