This file provides guidance to Claude Code when working with this repository.
Core: B2B service that assesses and educates AI builders' capabilities
Strategy: B2C (viral personality test) → B2B (enterprise capability assessment/training)
BetterPrompt analyzes AI builder sessions from ~/.claude/projects/, evaluates collaboration style using LLM analysis, and generates personalized reports.
⚠️ IMPORTANT: All content in this codebase MUST be written in English.
- LLM Prompts: All prompts for LLM analysis (Anthropic, etc.) must be in English
- Code: All code, variable names, function names, and comments must be in English
- Docstrings: All documentation strings and JSDoc comments must be in English
- Commit messages: All git commit messages must be in English
This ensures consistency across the codebase and maintains compatibility with LLM models which perform best with English prompts.
npm run dev # Start Next.js development server (port 3000)
npm run build # Build production bundle
npm run typecheck # Type check without emitting
npm test # Run all testsPlugin-Based Analysis: All LLM analysis runs locally via the Claude Code plugin (packages/plugin/). The server receives finished results via POST /api/analysis/sync and serves them to the dashboard. See docs/agent/PLUGIN.md for the plugin pipeline architecture.
JSONL Parsing: Session logs contain user, assistant, queue-operation, file-history-snapshot types. Only user and assistant are analyzed. Content blocks: text, tool_use, tool_result.
Path Encoding: Claude Code encodes paths by replacing / with -. See encodeProjectPath/decodeProjectPath in src/lib/parser/jsonl-reader.ts.
⚠️ Continuous Scroll Layout: The report page renders ALL worker sections sequentially (no tabs).useScrollSpyhook drives the active section indicator in theFloatingProgressDotscomponent.InsightPreviewCardis replaced by inline insight rendering withinGrowthCard.How it works (in
TabbedReportContainer.tsx):
- All sections (Activity, Thinking, Communication, Learning, Context, Session) render simultaneously
useScrollSpywith IntersectionObserver detects which section is in viewportFloatingProgressDots(fixed right side) highlights the active section- Professional insights render inline within
GrowthCard(no sidebar, no click needed)Key files:
useScrollSpy.ts,FloatingProgressDots.tsx,WorkerInsightsSection.tsx(inline insights in GrowthCard)
⚠️ CRITICAL: This codebase follows a strict "No Fallback" policy.
Principle: When errors occur, they must be thrown immediately. Never silently hide errors by returning default/empty data.
Why:
- Fallbacks hide bugs and make debugging extremely difficult
- Silent failures lead to incorrect analysis results being stored in the database
- Users get misleading data without knowing something went wrong
Implementation:
- Plugin analysis skills let errors propagate instead of returning empty data
- Frontend should show clear error states, not fake/empty results
Do NOT:
// BAD: Silent fallback hides errors
try {
return await analyze();
} catch (error) {
return createDefaultOutput(); // User gets empty data, thinks analysis succeeded
}Do:
// GOOD: Let errors propagate
return await analyze(); // Error surfaces to user, root cause can be identifiedThese deprecated code paths are kept intentionally for data migration. Do NOT remove.
| Location | Purpose |
|---|---|
src/lib/domain/models/knowledge.ts TopicCategorySchema |
Legacy topic categories for SQLite migration compatibility |
src/lib/models/verbose-evaluation.ts pipe-delimited parsers |
Legacy format parsers for cached analysis data from pre-structured-JSON era |
See docs/agent/DEPLOYMENT.md for the current self-hosted runtime model and defaults.
Self-hosted: npm run build && npm start
⚠️ Post-merge cleanup: After merging a PR, always switch back tomainand pull latest:git checkout main && git pull origin mainThis prevents accidentally continuing work on a stale feature branch.
⚠️ Clean Environment Required: When testing the BetterPrompt plugin, always remove all previous installations first to test the full flow including the installation step. A test that skips install doesn't reflect what a real user encounters.Cleanup checklist (all must be done before testing):
~/.claude/settings.json— setenabledPlugins["betterprompt@betterprompt"]tofalse, clearextraKnownMarketplaces~/.claude/plugins/installed_plugins.json— removebetterprompt@betterpromptentry~/.claude/plugins/known_marketplaces.json— removebetterpromptentry- Delete
~/.claude/plugins/cache/betterprompt/andtemp_local_*dirs- Delete
~/.claude/plugins/marketplaces/betterprompt/- Clear any project-level
settings.local.jsonwith betterprompt entries- Check for and remove any plugin state databases (
bp-results*,bp-stage*)- Delete
~/.betterprompt/prefs.jsonto reset first-run onboarding state- Validate all JSON files after edits (trailing comma issues are common)
⚠️ Context Loading: Before exploring the codebase for architecture, pipeline, file locations, or debugging context, readdocs/agent/first. These docs are optimized for fast lookups (concise, table-based) and cover most questions about system structure, key files, test workflows, and known issues. Only dive into source files whendocs/agent/doesn't have the specific detail you need.
| Document | When to Read |
|---|---|
| docs/agent/ARCHITECTURE.md | Understanding system structure, pipeline phases, finding key files, API routes, data models |
| docs/agent/TESTING.md | Running tests, test script options, cache workflows, plugin testing cleanup |
| docs/agent/DEPLOYMENT.md | Self-hosted deployment, runtime defaults |
| docs/agent/TROUBLESHOOTING.md | Debugging issues, known pitfalls, prevention checklists |
Detailed human-readable docs: docs/human/
⚠️ Keep Agent Docs Updated: When you add new files, change directory structure, modify the pipeline, add/remove API routes, or update test scripts, update the relevantdocs/agent/doc in the same change. These docs are the primary reference for future sessions — stale docs lead to wrong assumptions and wasted context.