Expert guidance for the claude-code-server WebSocket project - a remote Claude Code CLI interface with real-time streaming, functional architecture, and comprehensive testing.
This skill has safety concerns that you should review before use. Some patterns were detected that may pose a risk.Safety score: 60/100.
KillerSkills scans all public content for safety. Use caution before installing or executing flagged content.
Expert guidance for working with the claude-code-server codebase - a WebSocket server that provides a web interface for executing Claude Code CLI commands remotely with real-time output streaming.
This is a production-grade WebSocket server built with Express, Socket.io, and TypeScript. It manages child processes for Claude commands and streams output in real-time through WebSocket connections. The architecture emphasizes functional programming patterns, strong typing, and comprehensive test coverage.
When working on this project, follow these steps:
1. **Setup and Installation**
- Run `npm install` to install all dependencies
- Verify TypeScript and Jest are properly configured
- Check that the `claude` CLI is available in your environment
2. **Development Mode**
- Use `npm run dev` for hot-reload development
- The server will restart automatically on file changes
- Default port is 3000 (configurable via `PORT` environment variable)
- Access the web UI at `http://localhost:3000`
3. **Building**
- Run `npm run build` to compile TypeScript to JavaScript
- Output files are placed in the `./dist` directory
- Production server runs from compiled JavaScript: `npm start`
- Use `npm run start:dev` to build and start in one command
4. **Testing**
- Run `npm test` for single test execution
- Use `npm run test:watch` for continuous testing during development
- Generate coverage reports with `npm run test:coverage`
- All tests should pass before committing changes
This project uses **functional programming** and **strong typing** instead of class-based architecture:
1. **src/server.ts**
- Main server setup with Express and Socket.io
- HTTP endpoint configuration
- WebSocket initialization
- Server lifecycle management
2. **src/types.ts**
- Central type definitions for the entire project
- Key interfaces: `ProcessManager`, `ClaudeCommand`, `ProcessOutput`, `ServerConfig`
- All types are exported and reused throughout the codebase
3. **src/processManager.ts**
- Pure functions for process lifecycle management
- Functions operate on `ProcessManager` state object
- Process spawning: `claude -p [command]` pattern
- Single-process-per-client constraint
- Working directory validation and security
4. **src/socketHandlers.ts**
- Functional event handlers for Socket.io
- Compose process management functions with WebSocket communication
- Handle `execute-command`, `kill-process`, and related events
5. **public/index.html**
- Terminal-like web interface
- Embedded JavaScript for real-time communication
- User input and output display
The project uses **Jest with TypeScript support** (ts-jest):
Socket.io events:
- `execute-command`: Run a Claude command with optional relative working directory
- `kill-process`: Terminate the currently running process
- `output`: Stream command output (type: stdout/stderr/system/error)
- `process-killed`: Confirmation of successful process termination
1. **When Adding Features**
- Define types first in `src/types.ts`
- Write pure functions in appropriate modules
- Add unit tests for new functions
- Update integration tests if Socket.io events change
- Ensure working directory validation is maintained
2. **When Fixing Bugs**
- Write a failing test that reproduces the bug
- Fix the issue in the relevant functional module
- Verify all tests pass
- Check that security constraints still hold
3. **When Refactoring**
- Maintain functional programming patterns
- Keep functions pure and composable
- Preserve strong typing throughout
- Ensure test coverage remains high
- Do not introduce class-based patterns
4. **Code Style**
- Use explicit type annotations
- Prefer `const` over `let`
- Avoid mutation; use functional transformations
- Keep functions small and focused
- Document complex logic with comments
1. Define the event payload type in `src/types.ts`
2. Create a handler function in `src/socketHandlers.ts`
3. Register the event listener in `src/server.ts`
4. Add integration tests in `src/__tests__/server.test.ts`
5. Update the web UI in `public/index.html` if needed
1. Add new function(s) to `src/processManager.ts`
2. Ensure functions are pure and operate on `ProcessManager` state
3. Add unit tests in `src/__tests__/processManager.test.ts`
4. Update type definitions in `src/types.ts` if state shape changes
5. Compose new functions into socket handlers as needed
1. Update validation logic in `src/processManager.ts`
2. Add test cases in `src/__tests__/processManager.test.ts` to verify security
3. Document the security model changes in comments
4. Test directory traversal prevention thoroughly
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/claude-code-server-development/raw