Thank you for your interest in contributing to Cline! This guide will help you understand our development process and how you can contribute effectively.
- Development Setup
- Code Style Guide
- Testing Guidelines
- Architecture Decisions
- Pull Request Process
- Documentation Guidelines
- Clone the repository (Requires git-lfs):
git clone https://github.com/cline/cline.git
- Open the project in VSCode:
code cline
- Install dependencies for both extension and webview:
npm run install:all
- Launch by pressing
F5
to open a new VSCode window with the extension loaded.
Note: You may need to install the esbuild problem matchers extension if you run into build issues.
-
Type Safety
- Use explicit types for function parameters and returns
- Avoid
any
type unless absolutely necessary - Use interfaces for object shapes
- Leverage union types for message handling
-
Naming Conventions
- Use PascalCase for class names (e.g.,
TerminalManager
,BrowserSession
) - Use camelCase for variables and functions
- Use ALL_CAPS for constants (e.g.,
MAX_IMAGES_PER_MESSAGE
) - Use descriptive names that reflect purpose
- Use PascalCase for class names (e.g.,
-
File Organization
- Group related functionality in directories (api, core, integrations)
- Use index.ts files for clean exports
- Keep files focused and manageable
- Follow the established directory structure:
src/ ├── api/ # API provider implementations ├── core/ # Core extension functionality ├── integrations/ # VSCode integration features ├── services/ # Shared services └── utils/ # Utility functions
-
Component Structure
- Use functional components with hooks
- Implement proper prop typing
- Keep components focused on single responsibility
- Extract reusable logic into custom hooks
-
State Management
- Use ExtensionStateContext for global state
- Keep state as local as possible using useState
- Use useCallback for event handlers
- Implement useMemo for expensive computations
-
Performance Optimization
- Use virtualization for long lists (Virtuoso)
- Implement proper memo usage
- Handle scroll performance
- Manage re-renders efficiently
-
Event Handling
- Use proper event cleanup
- Implement debouncing where needed
- Handle VSCode message passing correctly
- Manage async operations properly
The project currently has a basic test infrastructure that we're working to expand:
-
Extension Tests
npm run test # Run extension tests npm run test:webview # Run webview tests
-
Test Files Location
- Extension tests in
src/test/
- Webview tests in
webview-ui/src/test/
- Extension tests in
-
Areas to Test
- Extension activation
- Command registration
- API provider integration
- Tool execution
- Message handling
-
Coverage Targets
- Implement comprehensive test suite
- Add integration tests
- Add unit tests for core functionality
- Implement end-to-end testing
-
Testing Standards
- Write descriptive test names
- Test error scenarios
- Mock external dependencies
-
Coverage Requirements
- Minimum 80% coverage for new code
- Focus on critical paths
- Test edge cases
- Include error scenarios
-
Running Tests
npm run test # Run all tests npm run test:watch # Run tests in watch mode npm run test:coverage # Generate coverage report
-
VSCode Extension Tests
- Test extension activation
- Verify command registration
- Test webview integration
- Validate settings management
-
API Integration Tests
- Test provider integrations
- Verify streaming behavior
- Test error handling
- Validate rate limiting
-
Core Components
- Extension entry point manages activation and commands
- ClineProvider handles webview and state
- Core Cline class implements AI assistant logic
- Tools system provides controlled automation
-
State Management
- Use VSCode extension context for persistence
- Implement proper cleanup on deactivation
- Handle state restoration on activation
- Maintain conversation history
-
Security Considerations
- Implement human-in-the-loop approvals
- Validate all file operations
- Sanitize command inputs
- Secure API key storage
-
Tool Implementation
- Each tool must be self-contained
- Implement proper error handling
- Provide clear success/failure indicators
- Document tool capabilities and limitations
-
Tool Integration
- Tools must be approved by user
- Tools should be atomic operations
- Implement proper cleanup
- Handle interruptions gracefully
-
Before Submitting
- Run
npm run compile
to verify build - Update documentation if needed
- Test your changes
- Follow code style guidelines
- Add tests for new features
- Ensure all tests pass
- Run
-
PR Requirements
- Clear description of changes
- Link to related issues
- Include test coverage plan
- Update CHANGELOG.md
-
Review Process
- Address review comments
- Keep PR scope focused
- Maintain clean commit history
- Update based on feedback
-
Code Documentation
- Use JSDoc for public APIs
- Document complex logic
- Keep comments current
- Include examples
-
Project Documentation
- Update README.md for user-facing changes
- Maintain project-documentation.md
- Document architectural decisions
- Keep CHANGELOG.md updated
-
Documentation Structure
- Clear and concise
- Include examples
- Keep formatting consistent
- Update table of contents
- Join our Discord community
- Check existing issues
- Review discussions
- Read our wiki
By contributing to Cline, you agree that your contributions will be licensed under the Apache 2.0 License.