Skip to content

saltpay/copycat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Copycat 😸

Welcome to Copycat, a way to copy changes from one git repository to another.

Copycat logo

Copycat is an automation tool that enables you to apply consistent changes across multiple GitHub repositories using AI coding assistants. It streamlines the process of creating issues or performing code changes at scale with support for multiple AI tools including Claude, Codex, Qwen, and others.

Requirements

In order to run Copycat, you need to have the following installed:

  • Go (1.16 or later)
  • GitHub CLI (gh) - Installation guide
  • AI Coding Assistant - At least one of:
    • Claude CLI (claude) - Installation guide
    • Codex (codex)
    • Qwen (qwen)
    • Gemini (gemini)
    • Or any other AI tool configured in config.yaml

Authentication Setup

Before using Copycat, ensure you're authenticated:

# Authenticate with GitHub
gh auth login

# Authenticate with your chosen AI tool (example with Claude)
claude auth login

Configuration

Copycat reads all settings from a single config.yaml file in the project root:

github:
  organization: saltpay
  auto_discovery_topic: copycat-subject
  requires_ticket_topic: requires-ticket
  slack_room_topic_prefix: slack-room/

tools:
  - name: claude
    command: claude
    code_args:
      - --permission-mode
      - acceptEdits
    summary_args: []
  - name: codex
    command: codex
    code_args:
      - exec
      - --full-auto
    summary_args: []
  - name: qwen
    command: qwen
    code_args:
      - --approval-mode
      - auto-edit
      - -p
    summary_args: []

Configuration Fields

  • github.organization: GitHub organization to scan for repositories
  • github.auto_discovery_topic (optional): GitHub topic Copycat passes to gh repo list; when omitted Copycat lists all repositories
  • github.requires_ticket_topic (optional): Topic that marks repositories as requiring a Jira ticket in PR titles
  • github.slack_room_topic_prefix (optional): Topic prefix used to infer the Slack room by stripping the prefix (e.g., slack-room/eng-tooling β†’ eng-tooling, slack-room/#eng-tooling β†’ #eng-tooling)
  • tools: List of AI tools available in the selector
    • name: Identifier for the tool
    • command: CLI command to execute
    • code_args: Arguments passed when making code changes
    • summary_args: Arguments passed when generating PR descriptions (optional)

When Copycat lists repositories it uses the configured discovery topic if provided, otherwise it fetches every unarchived repository in the organization. Any repository that also has the configured requires_ticket_topic is treated as requiring a Jira ticket in the PR title. If a repository includes a topic that starts with slack_room_topic_prefix, Copycat sends notifications to the derived Slack channel.

Usage

Quick Start

go run main.go

# Or build and run
go build -o copycat
./copycat

Workflow Options

Copycat offers two main workflows:

1. Create GitHub Issues

Creates GitHub issues across selected repositories and assigns them to @copilot.

Steps:

  1. Select repositories from the list (or type "all")
  2. Choose "Create GitHub Issues"
  3. Enter issue title
  4. Enter issue description
  5. Issues are created automatically

Note: The Copilot agent does not sign commits, so you'll need to fix unsigned commits before merging.

2. Perform Changes Locally

Clones repositories, applies changes using your configured AI coding assistant, and creates pull requests.

Steps:

  1. Select repositories from the list (or type "all")
  2. Choose "Perform Changes Locally"
  3. If any selected project includes the configured requires_ticket_topic, enter a Jira ticket (e.g., PROJ-123)
  4. Enter PR title
  5. Enter the AI prompt:
    • Single line: Type or paste the prompt and press Enter
    • Editor: Opens your default editor (set via $EDITOR env var, defaults to vim)
  6. Copycat will:
    • Clone all selected repositories to repos/ directory
    • Create a timestamped branch (e.g., copycat-20231015-150405)
    • Run your chosen AI tool to analyze and apply changes
    • Generate PR description automatically
    • Commit and push changes
    • Create pull requests
    • Clean up cloned repositories

Project Selection

When prompted for project numbers:

  • Enter specific numbers: 1,3,5
  • Enter a range: 1,2,3,4
  • Select all projects: all
  • Skip selection: press Enter

Branch Naming

Branches are automatically named with the format: copycat-YYYYMMDD-HHMMSS

Example: copycat-20231015-150405

Pull Request Titles

  • Regular projects: Uses the PR title you provide
  • Projects that require a ticket (repositories tagged with the configured requires_ticket_topic): Automatically prepends Jira ticket: PROJ-123 - Your PR Title

How It Works

Local Changes Workflow

  1. Input Collection Phase

    • Collects all user inputs upfront (Jira ticket, PR title, AI prompt)
    • Validates inputs before processing
  2. Repository Processing Phase

    • Cleans up existing repos/ directory
    • Clones selected repositories via SSH
    • Creates a new timestamped branch
    • Runs your configured AI tool with appropriate arguments (from config.yaml)
    • Captures AI output for PR description
  3. PR Generation Phase

    • Uses your AI tool to generate a concise PR description (2-3 sentences)
    • Commits changes using the PR title as commit message
    • Pushes branch to origin
    • Detects default branch automatically
    • Creates PR using GitHub CLI
    • Cleans up local repository clone

GitHub Issues Workflow

  1. Collects issue title and description
  2. Uses gh issue create to create issues
  3. Automatically assigns issues to @copilot
  4. Provides URLs of created issues

Directory Structure

copycat/
β”œβ”€β”€ main.go                     # Main application code
β”œβ”€β”€ config.yaml                 # Combined configuration (GitHub + AI tools)
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   └── ai.go              # AI tool integration logic
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ config.go          # Configuration loading
β”‚   β”‚   └── config_test.go     # Configuration tests
β”‚   β”œβ”€β”€ input/
β”‚   β”‚   └── ai_prompt.go       # User input handling
β”‚   β”œβ”€β”€ git/
β”‚   └── filesystem/
β”œβ”€β”€ go.mod                      # Go module dependencies
β”œβ”€β”€ go.sum                      # Go module checksums
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ copycat-logo.png            # Logo image
└── repos/                      # Temporary directory for cloned repos (auto-cleaned)

Troubleshooting

Common Issues

Git clone fails:

  • Ensure you have SSH access to the repositories
  • Check your SSH keys: ssh -T [email protected]

AI tool fails:

  • Verify your chosen AI tool is installed and in your PATH
  • Check authentication with your AI tool
  • Ensure repositories have proper file permissions
  • Verify the AI tool configuration in config.yaml is correct

PR creation fails:

  • Verify you're authenticated with GitHub CLI: gh auth status
  • Check that you have write access to the repositories
  • Ensure the base branch exists

No changes detected:

  • Your AI tool may not have made any modifications
  • Review your prompt for clarity
  • Check if the prompt applies to the specific repository
  • Verify the AI tool is configured correctly with appropriate arguments

Best Practices

  1. Test with a single repository first before running on all projects
  2. Use clear, specific prompts for your AI tool
  3. Review changes before merging PRs
  4. Keep Jira tickets handy for projects requiring a ticket
  5. Use the editor option for complex multi-line prompts
  6. Configure AI tool arguments properly in config.yaml for optimal results

Examples

Example Claude Prompts

Add a new dependency:

Add the package "github.com/stretchr/testify" to go.mod and run go mod tidy

Update documentation:

Add a CONTRIBUTING.md file with guidelines for: code style (use gofmt), testing requirements (minimum 80% coverage), and PR process (requires 2 approvals)

Refactor code:

Rename all instances of the function 'processData' to 'transformData' across the codebase. Ensure all tests are updated accordingly.

Security Notes

  • Copycat uses SSH for git operations
  • Credentials are managed via GitHub CLI and Claude CLI
  • No credentials are stored by Copycat
  • Repository clones are cleaned up after processing

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 9

Languages