| description | Use Bun instead of Node.js, npm, pnpm, or vite. |
|---|---|
| globs | *.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json |
| alwaysApply | false |
Default to using Bun instead of Node.js.
- Use
bun <file>instead ofnode <file>orts-node <file> - Use
bun testinstead ofjestorvitest - Use
bun build <file.html|file.ts|file.css>instead ofwebpackoresbuild - Use
bun installinstead ofnpm installoryarn installorpnpm install - Use
bun run <script>instead ofnpm run <script>oryarn run <script>orpnpm run <script> - Bun automatically loads .env, so don't use dotenv.
Bun.serve()supports WebSockets, HTTPS, and routes. Don't useexpress.bun:sqlitefor SQLite. Don't usebetter-sqlite3.Bun.redisfor Redis. Don't useioredis.Bun.sqlfor Postgres. Don't usepgorpostgres.js.WebSocketis built-in. Don't usews.- Prefer
Bun.fileovernode:fs's readFile/writeFile - Bun.$
lsinstead of execa.
Use bun test to run tests.
import { test, expect } from "bun:test";
test("hello world", () => {
expect(1).toBe(1);
});Use HTML imports with Bun.serve(). Don't use vite. HTML imports fully support React, CSS, Tailwind.
Server:
import index from "./index.html"
Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => {
return new Response(JSON.stringify({ id: req.params.id }));
},
},
},
// optional websocket support
websocket: {
open: (ws) => {
ws.send("Hello, world!");
},
message: (ws, message) => {
ws.send(message);
},
close: (ws) => {
// handle close
}
},
development: {
hmr: true,
console: true,
}
})HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. <link> tags can point to stylesheets and Bun's CSS bundler will bundle.
<html>
<body>
<h1>Hello, world!</h1>
<script type="module" src="./frontend.tsx"></script>
</body>
</html>With the following frontend.tsx:
import React from "react";
// import .css files directly and it works
import './index.css';
import { createRoot } from "react-dom/client";
const root = createRoot(document.body);
export default function Frontend() {
return <h1>Hello, world!</h1>;
}
root.render(<Frontend />);Then, run index.ts
bun --hot ./index.tsFor more information, read the Bun API docs in node_modules/bun-types/docs/**.md.
- OS: macOS (Darwin 23.6.0) with limited sudo access for system diagnostics
- Communication style: Expert level, concise responses preferred
- Boundaries: Will not kill critical system processes, prefers non-destructive debugging methods
- NEVER suggest killing system processes if user explicitly states they don't want to kill them
- Start with non-privileged tools (ps, top, Activity Monitor) before attempting sudo-required diagnostics
- If system diagnostic commands fail with permissions, immediately pivot to user-accessible alternatives
- For macOS system issues, always provide context about normal vs abnormal behavior before suggesting fixes
- Use basic process info commands first:
ps,top - If detailed inspection is needed and fails due to permissions, suggest Activity Monitor GUI
- Always explain both immediate fixes and long-term preventive measures
- Focus on monitoring and diagnostic approaches rather than destructive fixes
- Create structured plans with TodoWrite for complex system debugging tasks
- Track multiple diagnostic approaches systematically
src/
├── parsers/ # Claude Code JSONL file parsing
├── analyzers/ # AI insight extraction (pattern-matching + AI-powered)
├── exporters/ # Report generation in multiple formats
├── cli/ # Command-line interface
└── types/ # TypeScript type definitions
- Conversations stored in
~/.claude/projects/[project-hash]/[session-id].jsonl - Project names encoded as
-Users-username-path-to-project - Each JSONL line is a message with
type,timestamp,message,uuid, etc. - Need to handle
user,assistant,summary, andtool_resultmessage types
- Exact path match: Most reliable, matches encoded paths exactly
- Project name match: Fallback, matches last directory segment
- Partial path match: Last resort, matches common path segments
- Always pick most recently active project when multiple matches
- Pattern-matching: Fast, regex-based, good for basic insights
- AI-powered: Requires API key, deep contextual analysis, slower but much better
- Chunk conversations into ~45k token segments for API calls
- Use single comprehensive prompt for both insights and user patterns
# Test project detection
bun test-detector.ts
# Test simple analysis
bun test-simple-analyze.ts
# Test specific depth
bun run dev analyze --depth 20 --debug# Separate tsconfig for declarations to avoid conflicts
tsconfig.json # Main config with noEmit: true
tsconfig.build.json # Build config for declarations
# Fix TypeScript strict null issues with !
const first = messages[0]!; # Assert non-null- Indentation errors: Use consistent 2-space indentation
- API type issues: Cast Anthropic response content as
anyif needed - Progress bars: Use cli-progress for long-running operations
- Rate limiting: Add delays between API calls (1000ms recommended)
- Separate command functions in
cli/commands/for cleaner code - Use Commander.js options properly with string defaults
- Handle missing API keys gracefully with helpful error messages
- Unit tests: Test parsers and analyzers separately
- Integration tests: Test with real JSONL files
- Manual testing: Use current project as test case (meta!)
- Debug mode: Always provide debug options for troubleshooting
- Limit message analysis with
--depthparameter - Use
--recentflag to analyze only recent sessions - Chunk large conversations for memory efficiency
- Add progress indicators for long operations
# Required for AI-powered analysis
export ANTHROPIC_API_KEY=your_key_here
# Optional: faster package manager
export BUN_INSTALL="$HOME/.bun"# Development
bun run dev analyze --debug # Debug project detection
bun run dev analyze --depth 50 # Quick analysis
bun run dev analyze --ai-powered # Full AI analysis
# Build & Deploy
bun run build # Build for production
bun test # Run tests
node dist/cli.js analyze # Test built version- Add conversation threading analysis
- Implement conversation search/filtering
- Export to more formats (Excel, PDF)
- Add real-time analysis of active sessions
- Implement conversation comparison between projects