Contributing to Claude Agent Platform โ
Thank you for your interest in contributing to the Claude Agent Platform! This guide will help you get started with contributing to our open-source project.
๐ Table of Contents โ
- Getting Started
- Development Setup
- Project Structure
- Coding Standards
- Testing Guidelines
- Pull Request Process
- Code Review Process
- Release Process
- Community Guidelines
๐ Getting Started โ
Prerequisites โ
Before you begin contributing, ensure you have the following installed:
- Node.js 20+ (use nvm for version management)
- pnpm 8+ (package manager)
- Docker and Docker Compose
- Git (configured with your name and email)
Installation โ
Fork the repository
bash# Fork the repository on GitHub, then clone your fork git clone https://github.com/YOUR_USERNAME/platform.git cd platformAdd upstream remote
bashgit remote add upstream https://github.com/claude-agent/platform.gitInstall dependencies
bashpnpm installSet up development environment
bash# Copy environment variables cp .env.example .env # Start development services pnpm run docker:up # Install git hooks pnpm run setup:hooksVerify setup
bash# Run tests to ensure everything is working pnpm run test pnpm run lint pnpm run type-check
๐ ๏ธ Development Setup โ
Branch Strategy โ
We use a Git Flow branching strategy:
main: Production-ready code (protected branch)develop: Integration branch for featuresfeature/*: New features and enhancementsbugfix/*: Bug fixeshotfix/*: Critical fixes for productionrelease/*: Release preparation
Creating a Feature Branch โ
Sync with upstream
bashgit fetch upstream git checkout develop git merge upstream/developCreate feature branch
bashgit checkout -b feature/your-feature-nameStart development
bash# Start development servers pnpm run dev
Development Workflow โ
# 1. Make your changes
git add .
git commit -m "feat: add your feature description"
# 2. Run tests and quality checks
pnpm run test
pnpm run lint
pnpm run type-check
# 3. Push to your fork
git push origin feature/your-feature-name
# 4. Create Pull Request
# Open GitHub and create a PR from your branch to develop๐ Project Structure โ
Understanding the project structure is crucial for effective contributions:
claude-agent-platform/
โโโ .github/ # GitHub configuration
โ โโโ workflows/ # CI/CD workflows
โ โโโ ISSUE_TEMPLATE/ # Issue templates
โ โโโ PULL_REQUEST_TEMPLATE.md
โโโ packages/ # Core packages
โ โโโ api/ # NestJS API server
โ โ โโโ src/
โ โ โ โโโ auth/ # Authentication
โ โ โ โโโ agents/ # Agent management
โ โ โ โโโ tasks/ # Task execution
โ โ โ โโโ config/ # Configuration
โ โ โโโ test/ # API tests
โ โ โโโ package.json
โ โโโ database/ # Prisma database
โ โ โโโ schema.prisma # Database schema
โ โ โโโ migrations/ # Database migrations
โ โ โโโ seeds/ # Seed data
โ โโโ shared/ # Shared utilities
โ โโโ types/ # TypeScript types
โ โโโ monitoring/ # Observability
โโโ apps/ # Applications
โ โโโ web/ # Next.js web app
โ โโโ cli/ # Command-line interface
โ โโโ deployment/ # Deployment tools
โโโ luna-agents/ # Luna agents ecosystem
โ โโโ agents/ # Individual agents
โ โโโ .claude-plugin/ # Claude Code plugin
โ โโโ mcp-servers/ # MCP servers
โโโ tools/ # Development tools
โโโ docs/ # Documentation
โโโ tests/ # E2E and integration tests
โโโ infrastructure/ # Infrastructure as codeWhere to Make Changes โ
- Bug Fixes: Fix in the appropriate package or app
- New Features: Add to relevant package or create new one
- Documentation: Update in
docs/or alongside code changes - Tests: Add tests in
test/directories of each package - Configuration: Update in relevant config files
๐ Coding Standards โ
TypeScript Guidelines โ
We use strict TypeScript with comprehensive type coverage:
// โ
Good: Use explicit types
interface UserConfig {
id: string;
name: string;
email: string;
role: UserRole;
}
// โ
Good: Use generics for reusable code
interface Repository<T> {
findById(id: string): Promise<T | null>;
create(data: Partial<T>): Promise<T>;
update(id: string, data: Partial<T>): Promise<T>;
}
// โ Bad: Avoid 'any' type
function processData(data: any): any {
return data.processed;
}
// โ
Good: Use specific types
interface Processable {
process(): ProcessedData;
}
function processData<T extends Processable>(data: T): ProcessedData {
return data.process();
}Code Style โ
We enforce consistent code style using ESLint and Prettier:
// โ
Good: Consistent formatting
export class AgentService {
constructor(
private readonly repository: AgentRepository,
private readonly logger: Logger,
) {}
async createAgent(config: AgentConfig): Promise<Agent> {
try {
const agent = await this.repository.create(config);
this.logger.info(`Agent created: ${agent.id}`);
return agent;
} catch (error) {
this.logger.error('Failed to create agent', { error });
throw new AgentCreationError('Unable to create agent', error);
}
}
}Naming Conventions โ
- Files: kebab-case (
agent-service.ts,user-config.ts) - Classes: PascalCase (
AgentService,UserRepository) - Functions/Methods: camelCase (
createAgent,findById) - Constants: UPPER_SNAKE_CASE (
MAX_RETRY_ATTEMPTS,DEFAULT_TIMEOUT) - Interfaces: PascalCase with 'I' prefix for complex interfaces (
IAgentRepository) - Types: PascalCase (
UserRole,AgentStatus)
Error Handling โ
// โ
Good: Use custom error classes
export class AgentNotFoundError extends Error {
constructor(agentId: string) {
super(`Agent not found: ${agentId}`);
this.name = 'AgentNotFoundError';
}
}
// โ
Good: Handle errors gracefully
async function getAgent(id: string): Promise<Agent> {
try {
const agent = await agentRepository.findById(id);
if (!agent) {
throw new AgentNotFoundError(id);
}
return agent;
} catch (error) {
if (error instanceof AgentNotFoundError) {
throw error; // Re-throw domain errors
}
logger.error('Unexpected error getting agent', { id, error });
throw new InternalServerError('Failed to retrieve agent');
}
}๐งช Testing Guidelines โ
Test Structure โ
We follow the test pyramid approach:
tests/
โโโ unit/ # Fast, isolated unit tests
โโโ integration/ # Component integration tests
โโโ e2e/ # End-to-end tests
โโโ performance/ # Performance and load testsWriting Tests โ
Unit Tests โ
// agent.service.spec.ts
describe('AgentService', () => {
let service: AgentService;
let repository: jest.Mocked<AgentRepository>;
let logger: jest.Mocked<Logger>;
beforeEach(() => {
repository = createMockRepository();
logger = createMockLogger();
service = new AgentService(repository, logger);
});
describe('createAgent', () => {
it('should create an agent successfully', async () => {
// Arrange
const config: AgentConfig = {
name: 'Test Agent',
type: 'task-executor',
timeout: 30000,
};
const expectedAgent = createTestAgent(config);
repository.create.mockResolvedValue(expectedAgent);
// Act
const result = await service.createAgent(config);
// Assert
expect(result).toEqual(expectedAgent);
expect(repository.create).toHaveBeenCalledWith(config);
expect(logger.info).toHaveBeenCalledWith(
`Agent created: ${expectedAgent.id}`
);
});
it('should throw AgentCreationError when repository fails', async () => {
// Arrange
const config: AgentConfig = {
name: 'Test Agent',
type: 'task-executor',
timeout: 30000,
};
const error = new Error('Database error');
repository.create.mockRejectedValue(error);
// Act & Assert
await expect(service.createAgent(config)).rejects.toThrow(
AgentCreationError
);
expect(logger.error).toHaveBeenCalledWith(
'Failed to create agent',
{ error }
);
});
});
});Integration Tests โ
// agent.integration.spec.ts
describe('Agent API Integration', () => {
let app: INestApplication;
let prisma: PrismaService;
beforeAll(async () => {
const moduleFixture = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
prisma = moduleFixture.get<PrismaService>(PrismaService);
await app.init();
});
beforeEach(async () => {
await prisma.cleanDatabase(); // Helper to reset test data
});
afterAll(async () => {
await app.close();
});
describe('POST /api/agents', () => {
it('should create an agent', async () => {
const response = await request(app.getHttpServer())
.post('/api/agents')
.send({
name: 'Test Agent',
type: 'task-executor',
config: { timeout: 30000 },
})
.expect(201);
expect(response.body).toMatchObject({
name: 'Test Agent',
type: 'task-executor',
status: 'active',
});
});
});
});Test Requirements โ
- Coverage: Minimum 80% line coverage, 90% for critical paths
- Assertions: Every test should have at least one assertion
- Test Data: Use factories for test data generation
- Mocking: Mock external dependencies, don't mock the code you're testing
- Cleanup: Clean up test data in
afterEachhooks
Running Tests โ
# Run all tests
pnpm run test
# Run specific test file
pnpm run test packages/api/src/agents/agent.service.spec.ts
# Run tests in watch mode
pnpm run test:unit -- --watch
# Run tests with coverage
pnpm run test:coverage
# Run integration tests
pnpm run test:integration
# Run E2E tests
pnpm run test:e2e๐ Pull Request Process โ
Before Creating a PR โ
Ensure tests pass
bashpnpm run test pnpm run lint pnpm run type-checkUpdate documentation
- Update README.md if needed
- Add API documentation for new endpoints
- Update CHANGELOG.md for user-facing changes
Clean up commits
bash# Interactive rebase to clean up commit history git rebase -i HEAD~n
Creating a Pull Request โ
Push to your fork
bashgit push origin feature/your-feature-nameCreate PR on GitHub
- Base:
developbranch - Use descriptive title following Conventional Commits
- Fill out the PR template completely
- Link related issues
- Base:
PR Template
markdown## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update ## Testing - [ ] Unit tests pass - [ ] Integration tests pass - [ ] Manual testing completed ## Checklist - [ ] Code follows project style guidelines - [ ] Self-review completed - [ ] Documentation updated - [ ] Changes generate no new warnings
PR Review Process โ
Automated Checks
- CI/CD pipeline must pass
- Code coverage requirements met
- Security scans pass
Code Review
- At least one maintainer approval required
- Address all review comments
- Update PR based on feedback
Merge
- Squash and merge for feature branches
- Maintainers handle merge to maintain clean history
- PR is deleted after merge
๐ Code Review Process โ
Review Guidelines โ
When reviewing code, focus on:
Correctness
- Does the code work as intended?
- Are there edge cases not handled?
- Is error handling appropriate?
Performance
- Are there performance implications?
- Is database access optimized?
- Are algorithms efficient?
Security
- Are there security vulnerabilities?
- Is input validation proper?
- Are sensitive data handled correctly?
Maintainability
- Is code readable and understandable?
- Are naming conventions followed?
- Is code structure logical?
Testing
- Are tests comprehensive?
- Do tests cover edge cases?
- Are test assertions meaningful?
Review Comments โ
Use the following guidelines for review comments:
# Suggestions
**Suggestion**: Consider using async/await instead of .then() for better readability.
# Questions
**Question**: Why did you choose this approach over the alternative?
# Issues
**Issue**: This could potentially cause a memory leak if not properly cleaned up.
# Approval
**Approval**: Looks good! The tests cover all edge cases and the implementation is clean.๐ฆ Release Process โ
Version Management โ
We use Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Release Steps โ
Prepare release
bash# Update version pnpm run changeset pnpm run version # Update CHANGELOG pnpm run changeset changelogCreate release branch
bashgit checkout -b release/v1.2.0Final testing
bashpnpm run test pnpm run buildMerge and tag
bashgit checkout main git merge release/v1.2.0 git tag v1.2.0 git checkout develop git merge release/v1.2.0Publish
bashgit push origin main --tags pnpm run release
Release Notes โ
Generate release notes automatically:
# Generate release notes
pnpm run changeset changelog
# Or manually using GitHub releases๐ Community Guidelines โ
Code of Conduct โ
We are committed to providing a welcoming and inclusive environment. Please read our Code of Conduct and follow it in all interactions.
Communication Channels โ
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: General questions and community discussions
- Discord: Real-time chat and community support (link in README)
Getting Help โ
If you need help contributing:
- Check existing issues and documentation
- Search GitHub Discussions for similar questions
- Create a discussion for general questions
- Open an issue for specific bugs or feature requests
First-Time Contributors โ
We welcome first-time contributors! Look for issues labeled good first issue to get started:
- Find an issue labeled
good first issue - Comment that you'd like to work on it
- Follow the setup instructions above
- Ask for help if you get stuck
Recognition โ
Contributors are recognized in several ways:
- Contributors section in README
- Release notes mention significant contributors
- Contributor badge on GitHub profile
- Annual recognition for top contributors
๐ฏ Contribution Areas โ
We welcome contributions in many areas:
๐ค Agent Development โ
- Create new specialized agents
- Improve existing agent capabilities
- Add new agent integrations
๐ง AI Integration โ
- Support for new AI providers
- Enhanced RAG capabilities
- Token optimization improvements
๐ฑ Platform Generation โ
- New app generators (Flutter, .NET, etc.)
- Improved template systems
- Enhanced deployment automation
๐จ UI/UX Improvements โ
- New component designs
- Accessibility enhancements
- Performance optimizations
๐ Monitoring and Observability โ
- New metrics and dashboards
- Enhanced alerting
- Performance monitoring
๐ Documentation โ
- Improve existing documentation
- Add tutorials and guides
- Translate documentation
๐งช Testing โ
- Improve test coverage
- Add new test types
- Performance testing
๐ง DevOps and Infrastructure โ
- CI/CD improvements
- Deployment automation
- Infrastructure enhancements
๐ Getting Help โ
If you need help with contributing:
- Check the documentation first
- Search existing issues and discussions
- Join our Discord community
- Create a discussion for questions
- Contact maintainers for urgent issues
๐ Thank You โ
Thank you for contributing to the Claude Agent Platform! Your contributions help make this project better for everyone. We appreciate your time and effort in improving our open-source project.
Happy contributing! ๐