Skip to content

Commit 3695d33

Browse files
committed
docs: add Claude Code configuration
Add CLAUDE.md to help Claude Code (claude.ai/code) better understand: - Project architecture and monorepo structure - Key commands for development, building, and testing - Supported ecosystems (bundlers, frameworks, editors) - Common development patterns and debugging approaches This improves the development experience when using Claude Code as a coding assistant.
1 parent 6680218 commit 3695d33

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

CLAUDE.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
**Code Inspector** is a development productivity tool that enables developers to click on DOM elements in their browser and automatically open their IDE at the exact source code location. It supports multiple bundlers, frameworks, and code editors.
8+
9+
## Key Commands
10+
11+
### Development
12+
```bash
13+
# Install dependencies (uses pnpm workspaces)
14+
pnpm install
15+
16+
# Build all packages
17+
pnpm run build
18+
19+
# Build specific package
20+
pnpm run build --filter @code-inspector/core
21+
22+
# Watch mode for development
23+
pnpm run dev
24+
25+
# Run tests
26+
pnpm run test
27+
28+
# Run tests with coverage
29+
pnpm run test:coverage
30+
31+
# Run a single test file
32+
pnpm run test path/to/test.spec.ts
33+
34+
# Lint code
35+
pnpm run lint
36+
37+
# Type checking
38+
pnpm run typecheck
39+
```
40+
41+
### Version Management
42+
```bash
43+
# Update version for all packages
44+
pnpm run version
45+
46+
# Publish to npm
47+
pnpm run publish
48+
```
49+
50+
## Architecture
51+
52+
### Monorepo Structure
53+
- **packages/core**: Core functionality for code transformation, source mapping, and client-server communication
54+
- **packages/code-inspector-plugin**: Unified plugin entry that dispatches to bundler-specific implementations
55+
- **packages/vite-plugin**: Vite-specific plugin implementation
56+
- **packages/webpack-plugin**: Webpack 4/5 plugin implementation
57+
- **packages/rspack-plugin**: Rspack plugin implementation
58+
- **packages/turbopack-plugin**: Turbopack plugin implementation
59+
- **packages/esbuild-plugin**: ESBuild plugin implementation
60+
- **packages/mako-plugin**: Mako bundler plugin implementation
61+
62+
### Core Components
63+
64+
#### Transform System (packages/core/src/transform/)
65+
- **transform.ts**: Main transformation engine that processes source files
66+
- **ast.ts**: AST manipulation for accurate code location tracking
67+
- **vue.ts, jsx.ts, svelte.ts**: Framework-specific transformations
68+
- Preserves accurate mapping between original and compiled code
69+
70+
#### Client-Server Communication
71+
- **server.ts**: WebSocket server for browser-IDE communication
72+
- **client.ts**: Browser injection script for element interaction
73+
- Protocol: Browser → Server (element location) → IDE (file opening)
74+
75+
#### Source Mapping
76+
- Tracks transformations through bundler pipelines
77+
- Maintains accurate line/column mappings
78+
- Handles complex scenarios like JSX, Vue templates, and Svelte components
79+
80+
### Plugin Architecture
81+
1. **Unified Entry**: `code-inspector-plugin` provides single import
82+
2. **Auto-detection**: Detects bundler type and loads appropriate implementation
83+
3. **Consistent API**: All plugins share common interface despite bundler differences
84+
85+
## Supported Ecosystems
86+
87+
### Bundlers
88+
- Webpack 4/5 (via loader and plugin)
89+
- Vite 2/3/4/5
90+
- Rspack
91+
- Turbopack
92+
- ESBuild
93+
- Mako
94+
95+
### Frameworks
96+
- Vue 2/3 (SFC, JSX, TSX)
97+
- React (JSX, TSX)
98+
- Next.js (App Router, Pages Router)
99+
- Svelte
100+
- Qwik
101+
- Solid
102+
- Preact
103+
- Nuxt
104+
- Remix
105+
- Astro
106+
107+
### Editors
108+
- VSCode (including WSL, remote SSH)
109+
- WebStorm
110+
- Cursor
111+
- HBuilderX
112+
- VSCode Insiders
113+
- Custom editor support via configuration
114+
115+
## Key Technical Patterns
116+
117+
### Transform Pipeline
118+
1. Source file enters bundler
119+
2. Plugin intercepts and transforms code
120+
3. Injects tracking attributes (data-inspector-*)
121+
4. Preserves source maps throughout
122+
5. Client script detects clicks and sends location
123+
6. Server maps back to original file location
124+
125+
### Configuration Handling
126+
- Auto-detects framework and bundler
127+
- Minimal configuration required
128+
- Supports advanced customization via config object
129+
- Environment-aware (dev only by default)
130+
131+
### Cross-Platform Considerations
132+
- Path normalization for Windows/Unix
133+
- Editor detection across operating systems
134+
- URL handling for various development servers
135+
136+
## Testing Approach
137+
138+
Tests use Vitest and are located alongside source files as `*.spec.ts`. Key areas:
139+
- Transform accuracy for each framework
140+
- Source map preservation
141+
- Server-client communication
142+
- Editor integration
143+
- Bundle compatibility
144+
145+
## Common Development Tasks
146+
147+
### Adding New Bundler Support
148+
1. Create new package in `packages/[bundler]-plugin`
149+
2. Implement core plugin interface
150+
3. Add to unified plugin dispatcher
151+
4. Add demo project in `demos/`
152+
5. Update documentation
153+
154+
### Debugging Transform Issues
155+
1. Check `packages/core/src/transform/[framework].ts`
156+
2. Verify AST manipulation preserves locations
157+
3. Test with corresponding demo project
158+
4. Use `DEBUG=code-inspector:*` for verbose logging
159+
160+
### Fixing Source Map Issues
161+
1. Trace through transform pipeline
162+
2. Check line/column offset calculations
163+
3. Verify bundler-specific source map handling
164+
4. Test with real-world project structures

0 commit comments

Comments
 (0)