Thank you for your interest in contributing to Code Audit MCP! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Workflow
- Code Standards
- Testing Guidelines
- Submitting Changes
- Reporting Issues
- Feature Requests
- Documentation
- Community
This project adheres to a code of conduct that all contributors are expected to follow:
- Be respectful: Treat everyone with respect and kindness
- Be constructive: Provide helpful feedback and suggestions
- Be inclusive: Welcome contributors of all backgrounds and experience levels
- Be professional: Keep discussions focused on the project
Before contributing, ensure you have:
- Node.js v18.0.0 or higher
- npm v8.0.0 or higher
- Git installed and configured
- Ollama installed for testing
- VS Code (recommended) or your preferred editor
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/code-audit-mcp.git
cd code-audit-mcp- Add the upstream remote:
git remote add upstream https://github.com/warrengates/code-audit-mcp.git- Keep your fork updated:
git fetch upstream
git checkout main
git merge upstream/main# Install dependencies (includes husky setup)
npm install
# Build the project
npm run build
# Run quality checks to ensure everything is working
npm run quality-check
# Test the installation
npm run test-localIf using VS Code, install recommended extensions:
# Option 1: Accept workspace recommendations when prompted
# Option 2: Install manually
code --install-extension dbaeumer.vscode-eslint
code --install-extension esbenp.prettier-vscode
code --install-extension ms-vscode.vscode-typescript-next
code --install-extension usernamehw.errorlensThis project uses automatic pre-commit hooks that run:
- ESLint: Code quality and error checking
- Prettier: Code formatting
- TypeScript: Type checking
These run automatically on commit, but you can run them manually:
# Run all checks
npm run quality-check
# Fix auto-fixable issues
npm run quality-fix
# Individual checks
npm run lint # ESLint
npm run format:check # Prettier
npm run type-check # TypeScriptUse descriptive branch names:
feature/add-new-auditor- New featuresfix/security-audit-bug- Bug fixesdocs/update-readme- Documentationrefactor/improve-performance- Code refactoringtest/add-unit-tests- Test additions
- Create a new branch:
git checkout -b feature/your-feature-name-
Make your changes following our code standards
-
Test your changes:
# Run tests
npm test
# Test locally
npm run test-local
# Run specific auditor
npm run dev- Commit your changes:
# Stage changes
git add .
# Commit with descriptive message
git commit -m "feat: add support for Ruby security auditing"Follow the Conventional Commits specification:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, etc.)refactor:- Code refactoringtest:- Test additions or changeschore:- Build process or auxiliary tool changesperf:- Performance improvements
Examples:
feat: add Python Django framework-specific checks
fix: resolve memory leak in performance auditor
docs: update installation instructions for Windows
refactor: simplify model selection strategy
test: add unit tests for security auditor
- Use TypeScript strict mode
- Provide type annotations for all function parameters and return types
- Avoid
anytype - useunknownor specific types - Use interfaces for object shapes
- Document complex types with JSDoc comments
// Good
interface AuditRequest {
code: string;
language: string;
auditType?: AuditType;
}
function processAudit(request: AuditRequest): Promise<AuditResult> {
// Implementation
}
// Avoid
function processAudit(request: any): any {
// Implementation
}- Follow the configured ESLint and Prettier rules
- Use meaningful variable and function names
- Keep functions focused and small (single responsibility)
- Add comments for complex logic
- Use async/await over callbacks
- Handle errors appropriately
// Good
async function analyzeCode(code: string): Promise<AnalysisResult> {
try {
const parsed = await parseCode(code);
const issues = await findIssues(parsed);
return { success: true, issues };
} catch (error) {
logger.error('Code analysis failed:', error);
throw new AnalysisError('Failed to analyze code', { cause: error });
}
}
// Avoid
function analyzeCode(code, callback) {
parseCode(code, (err, parsed) => {
if (err) callback(err);
else findIssues(parsed, callback);
});
}- One component/class per file
- Group related functionality in directories
- Use barrel exports (index.ts) for clean imports
- Keep test files next to source files or in tests/
src/
├── auditors/
│ ├── index.ts # Barrel export
│ ├── base.ts # Base class
│ ├── security.ts # Security auditor
│ └── security.test.ts # Tests
- Write tests for all new functionality
- Aim for >80% code coverage
- Test edge cases and error conditions
- Use descriptive test names
describe('SecurityAuditor', () => {
describe('detectSQLInjection', () => {
it('should detect direct string interpolation in SQL queries', async () => {
const code = `const query = \`SELECT * FROM users WHERE id = \${userId}\`;`;
const issues = await auditor.audit(code);
expect(issues).toHaveLength(1);
expect(issues[0].type).toBe('sql_injection');
});
it('should not flag parameterized queries', async () => {
const code = `const query = 'SELECT * FROM users WHERE id = ?';`;
const issues = await auditor.audit(code);
expect(issues).toHaveLength(0);
});
});
});# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm run test:coverage
# Run specific test file
npm test -- security.test.ts- Ensure all tests pass and coverage is maintained
- Update documentation if needed
- Push your branch to your fork
- Create a pull request with:
- Clear title describing the change
- Description of what and why
- Link to related issues
- Screenshots if UI changes
## Description
Brief description of the changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests pass locally
- [ ] Added new tests
- [ ] Updated existing tests
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-reviewed code
- [ ] Commented complex code
- [ ] Updated documentation
- [ ] No new warnings- PRs require at least one review
- Address review feedback promptly
- Keep PRs focused and reasonably sized
- Be patient - reviews take time
When reporting bugs, include:
- Description: Clear description of the issue
- Steps to Reproduce: Minimal steps to reproduce
- Expected Behavior: What should happen
- Actual Behavior: What actually happens
- Environment: OS, Node version, Ollama version
- Code Sample: Minimal code that triggers the issue
- Error Messages: Full error output
**Describe the bug**
A clear description of the bug
**To Reproduce**
1. Run command '...'
2. With code '...'
3. See error
**Expected behavior**
What you expected to happen
**Environment:**
- OS: [e.g., macOS 14.0]
- Node: [e.g., 18.17.0]
- Ollama: [e.g., 0.1.20]
- Model: [e.g., codellama:7b]
**Additional context**
Any other relevant informationWhen requesting features:
- Use Case: Describe the problem you're trying to solve
- Proposed Solution: Your suggested approach
- Alternatives: Other solutions you've considered
- Additional Context: Examples, mockups, or references
- Keep README.md updated with significant changes
- Update inline code documentation
- Add examples for new features
- Ensure all public APIs are documented
/**
* Analyzes code for security vulnerabilities
*
* @param code - The source code to analyze
* @param options - Analysis options
* @returns Promise resolving to found security issues
*
* @example
* ```typescript
* const issues = await analyzeSecurityt(code, {
* severity: ['critical', 'high'],
* includeFixSuggestions: true
* });
* ```
*/
export async function analyzeSecurity(
code: string,
options: SecurityOptions
): Promise<SecurityIssue[]> {
// Implementation
}- Check existing issues and discussions
- Ask questions in GitHub Discussions
- Review the documentation and examples
- Be specific about your problem
- Answer questions in discussions
- Review pull requests
- Improve documentation
- Share your use cases
Contributors are recognized in:
- The project README
- Release notes
- GitHub contributors page
Thank you for contributing to Code Audit MCP!