Copycat Repository Automation
You are an AI assistant helping with the **Copycat** project—a Go-based CLI tool that automates consistent changes across multiple GitHub repositories using Claude AI.
Project Purpose
Copycat is a force multiplier for platform engineering teams managing many repositories. It enables:
**Scaling code changes** across multiple repositories efficiently**Maintaining consistency** in codebases, dependencies, and configurations**Reducing manual toil** in repetitive cross-repository tasks**Accelerating platform engineering** initiatives**Enabling AI-driven code transformations** at scaleCommon Use Cases
Dependency updates across multiple servicesSecurity patches and vulnerability fixesConfiguration standardizationDocumentation updatesCode refactoring and modernizationPolicy enforcement (linting rules, CI/CD configs)Migration tasks (API changes, framework upgrades)Architecture Overview
Core Components
1. **GitHub Repository Topics**: Support metadata like Slack channels and Jira tickets
2. **Main Application (`main.go`)**: Interactive CLI using `promptui` with two primary workflows:
- GitHub Issues workflow
- Local Changes workflow
3. **Integration Points**:
- **GitHub CLI (`gh`)**: Issue/PR management
- **Claude CLI (`claude`)**: AI-powered code changes
- **Git**: Repository operations
Key Design Patterns
**Input Collection Phase**: Gather all user inputs upfront before operations**Batch Processing**: Iterate through selected repositories sequentially**Auto-cleanup**: Remove temporary `repos/` directory after processing**Error Tolerance**: Continue processing remaining repos if one fails**Non-interactive Mode**: Claude runs with `--permission-mode acceptEdits`Code Style Guidelines
Go Conventions
Use **standard Go formatting** (`gofmt`)**Check all errors** and log with context**Variable naming**: - Descriptive names for complex logic
- Short names (`err`, `cmd`) for common patterns
**Comments**: Explain "why" not "what"Project-Specific Conventions
**Branch naming**: `copycat-YYYYMMDD-HHMMSS` (timestamp-based)**Commit messages**: Use PR title as commit message**PR titles**: - Projects requiring a ticket: `JIRA-123 - Description`
- Regular projects: `Description`
**Repository cloning**: Always use SSH URLs**Directory structure**: Temporary clones in `repos/` subdirectoryError Handling
**Log and continue**: Don't let one repository failure block others**User-friendly messages**: Prefix with ✓ or ⚠️**Contextual errors**: Include repository name in error messages**Graceful degradation**: Fallback to defaults (e.g., default branch detection)Development Instructions
When Adding Features
1. **Consider both workflows**: GitHub Issues and Local Changes
2. **Validate inputs early**: Before any git operations
3. **Maintain idempotency**: Operations should be safe to retry
4. **Add progress indicators**: Keep users informed
5. **Test error paths**: Ensure graceful failure handling
Testing Best Practices
Test with a **single repo first** before running on "all"Verify **cleanup** of `repos/` directoryCheck **authentication** for both `gh` and `claude`Ensure **SSH keys** are configured for git clone operationsValidate **write access** to repositoriesDependencies
Keep dependencies minimal. Current dependencies:
`github.com/manifoldco/promptui`: Interactive CLI prompts`gopkg.in/yaml.v3`: YAML configuration parsingPrefer standard library when possible.
Business Rules
Projects Requiring a Ticket
**Mandatory Jira ticket**: PR title must include Jira reference**Format**: `JIRA-123 - Description`**Detection**: Based on repository topic from config file**Validation**: Tool prompts for Jira ticket if applicable projects are selectedPull Request Creation
**Auto-generated descriptions**: Claude generates PR body from changes**Length limit**: PR descriptions truncated at 2000 characters**Base branch**: Dynamically detected (usually `main` or `master`)GitHub Issues Workflow
**Auto-assignment**: Issues assigned to `@copilot`**Bulk creation**: Creates issues across all selected repos**Warning**: Copilot doesn't sign commits (displayed to user)AI Assistant Guidelines
When working on this codebase:
1. **Preserve core workflow**: Input collection → Processing → Cleanup
2. **Maintain error tolerance**: Individual failures shouldn't block batch operations
3. **Keep it simple**: Avoid over-engineering edge cases
4. **User experience matters**: Provide clear prompts and progress indicators
5. **Test thoroughly**: Especially git operations and cleanup
6. **Document business rules**: Such as Jira ticket requirements
7. **Consider scale**: Changes should work for 1 repo or 100 repos
8. **Security first**: Never compromise authentication or credentials
Example Workflow
1. **Input Collection**: User selects repositories, provides PR title, change description
2. **Batch Processing**: For each repository:
- Clone to `repos/` directory
- Create timestamped branch
- Run Claude with change description
- Commit changes
- Create pull request
3. **Cleanup**: Remove `repos/` directory
4. **Report**: Display success/failure summary