Skip to content

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 โ€‹

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 โ€‹

  1. Fork the repository

    bash
    # Fork the repository on GitHub, then clone your fork
    git clone https://github.com/YOUR_USERNAME/platform.git
    cd platform
  2. Add upstream remote

    bash
    git remote add upstream https://github.com/claude-agent/platform.git
  3. Install dependencies

    bash
    pnpm install
  4. Set up development environment

    bash
    # Copy environment variables
    cp .env.example .env
    
    # Start development services
    pnpm run docker:up
    
    # Install git hooks
    pnpm run setup:hooks
  5. Verify 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 features
  • feature/*: New features and enhancements
  • bugfix/*: Bug fixes
  • hotfix/*: Critical fixes for production
  • release/*: Release preparation

Creating a Feature Branch โ€‹

  1. Sync with upstream

    bash
    git fetch upstream
    git checkout develop
    git merge upstream/develop
  2. Create feature branch

    bash
    git checkout -b feature/your-feature-name
  3. Start development

    bash
    # Start development servers
    pnpm run dev

Development Workflow โ€‹

bash
# 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 code

Where 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:

typescript
// โœ… 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:

typescript
// โœ… 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 โ€‹

typescript
// โœ… 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 tests

Writing Tests โ€‹

Unit Tests โ€‹

typescript
// 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 โ€‹

typescript
// 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 afterEach hooks

Running Tests โ€‹

bash
# 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 โ€‹

  1. Ensure tests pass

    bash
    pnpm run test
    pnpm run lint
    pnpm run type-check
  2. Update documentation

    • Update README.md if needed
    • Add API documentation for new endpoints
    • Update CHANGELOG.md for user-facing changes
  3. Clean up commits

    bash
    # Interactive rebase to clean up commit history
    git rebase -i HEAD~n

Creating a Pull Request โ€‹

  1. Push to your fork

    bash
    git push origin feature/your-feature-name
  2. Create PR on GitHub

    • Base: develop branch
    • Use descriptive title following Conventional Commits
    • Fill out the PR template completely
    • Link related issues
  3. 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 โ€‹

  1. Automated Checks

    • CI/CD pipeline must pass
    • Code coverage requirements met
    • Security scans pass
  2. Code Review

    • At least one maintainer approval required
    • Address all review comments
    • Update PR based on feedback
  3. 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:

  1. Correctness

    • Does the code work as intended?
    • Are there edge cases not handled?
    • Is error handling appropriate?
  2. Performance

    • Are there performance implications?
    • Is database access optimized?
    • Are algorithms efficient?
  3. Security

    • Are there security vulnerabilities?
    • Is input validation proper?
    • Are sensitive data handled correctly?
  4. Maintainability

    • Is code readable and understandable?
    • Are naming conventions followed?
    • Is code structure logical?
  5. Testing

    • Are tests comprehensive?
    • Do tests cover edge cases?
    • Are test assertions meaningful?

Review Comments โ€‹

Use the following guidelines for review comments:

markdown
# 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 โ€‹

  1. Prepare release

    bash
    # Update version
    pnpm run changeset
    pnpm run version
    
    # Update CHANGELOG
    pnpm run changeset changelog
  2. Create release branch

    bash
    git checkout -b release/v1.2.0
  3. Final testing

    bash
    pnpm run test
    pnpm run build
  4. Merge and tag

    bash
    git checkout main
    git merge release/v1.2.0
    git tag v1.2.0
    
    git checkout develop
    git merge release/v1.2.0
  5. Publish

    bash
    git push origin main --tags
    pnpm run release

Release Notes โ€‹

Generate release notes automatically:

bash
# 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:

  1. Check existing issues and documentation
  2. Search GitHub Discussions for similar questions
  3. Create a discussion for general questions
  4. 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:

  1. Find an issue labeled good first issue
  2. Comment that you'd like to work on it
  3. Follow the setup instructions above
  4. 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:

  1. Check the documentation first
  2. Search existing issues and discussions
  3. Join our Discord community
  4. Create a discussion for questions
  5. 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! ๐ŸŽ‰

Built with โค๏ธ for developers