Project: Sourcegraph

Sourcegraph thumbnail 1
Sourcegraph thumbnail 2
Sourcegraph thumbnail 3
Sourcegraph thumbnail 4
Sourcegraph thumbnail 5
Sourcegraph thumbnail 6
Sourcegraph thumbnail 7
Sourcegraph main image

Cody Batch - Autonomous Repository Remediation

Sourcegraph

Web ApplicationServerless

An AI-powered tool that leverages Claude 3.7 to perform bulk changes on GitHub repositories, automatically analyzing code and applying changes based on specific prompts.

Completion DateMarch 24, 2025
Project Day6 of 10

Project Demo

Project Metrics

10
Hours Spent
9,778
Lines of Code
5,772
Lines of Markdown
$85.97
LLM Cost

Project Details

Cody Batch increases developer productivity by automating repetitive code maintenance tasks across multiple repositories, demonstrating understanding of Sourcegraph's vision for AI coding agents. It addresses code maintenance at scale, technical debt reduction, and consistency enforcement.

Business Value

  • Developer Productivity
  • Code Maintenance

Key Features

Job Creation Interface

User-friendly form for creating batch change jobs with repository selection, custom prompt input, and option to automatically create pull requests.

Batch Processing System

AWS Batch for long-running job processing with container-based job execution, parallel processing of multiple repositories, and comprehensive error handling.

Claude 3.7 Integration

Tool-based interaction for repository analysis, autonomous code modification sessions, and token usage tracking and optimization.

GitHub Integration

Repository scanning and cloning, code analysis and modification, pull request creation for owned repositories, and diff generation for non-owned repositories.

Technologies Used

Frontend

ReactTypeScriptCSS ModulesTanstack Router

Backend

Node.jsExpressAWS LambdaAWS BatchZod

DevOps

AWS CDKDynamoDBDockerS3CloudFront

Other

Claude 3.7 APIGitHub APITool-based AI Interaction

Challenges & Solutions

Long-running job processing exceeding Lambda's 15-minute limit

Implemented AWS Batch for job processing, allowing jobs to run for extended periods while maintaining a serverless architecture for the API.

Claude API integration with proper error handling and token management

Developed a comprehensive Claude client with direct API calls, detailed logging, and token usage tracking, ensuring robust interaction with the Claude 3.7 API.

GitHub API rate limiting for repository operations

Implemented rate limit checking and management in the GitHub client, with exponential backoff and retry logic to handle rate limit constraints.

Key Learnings

  • Tool-Based AI Interaction: The tool-based approach for AI interaction proved highly effective for repository operations, providing structured interaction with clear boundaries and better control over the AI's actions.
  • AWS Batch for Long-Running Jobs: Using AWS Batch for job processing allowed for handling complex, long-running tasks that would exceed Lambda's timeout limits, while maintaining a serverless architecture for the API.
  • Conversation History Storage: Storing complete conversation histories, including tool calls and results, provided valuable context for understanding the AI's reasoning and debugging issues.
  • Direct API Calls vs. SDK: Using direct API calls with fetch instead of relying solely on the SDK provided better error handling, debugging, and compatibility with newer Claude models.