Prime your repositories for AI-assisted development.
Primer is a CLI tool that analyzes your codebase and generates .github/copilot-instructions.md files to help AI coding assistants understand your project better. It supports single repos, batch processing across organizations, and includes an evaluation framework to measure instruction effectiveness.
- Repository Analysis - Detects languages, frameworks, and package managers
- AI-Powered Generation - Uses the Copilot SDK to analyze your codebase and generate context-aware instructions
- Batch Processing - Process multiple repos across organizations with a single command
- Evaluation Framework - Test and measure how well your instructions improve AI responses
- GitHub Integration - Clone repos, create branches, and open PRs automatically
- Interactive TUI - Beautiful terminal interface built with Ink
- Config Generation - Generate MCP and VS Code configurations
- Node.js 18+
- GitHub Copilot CLI - Installed via VS Code's Copilot Chat extension
- Copilot CLI Authentication - Run
copilotthen/loginto authenticate - GitHub CLI (optional) - For batch processing and PR creation:
brew install gh && gh auth login
# Clone and install
git clone https://github.com/pierceboggan/primer.git
cd primer
npm installThe easiest way to get started is with the init command:
# Interactive setup for current directory
npx tsx src/index.ts init
# Accept defaults and generate instructions automatically
npx tsx src/index.ts init --yes
# Work with a GitHub repository
npx tsx src/index.ts init --github# Run TUI in current directory
npx tsx src/index.ts tui
# Run on a specific repo
npx tsx src/index.ts tui --repo /path/to/repo
# Skip the animated intro
npx tsx src/index.ts tui --no-animationKeys:
[A]Analyze - Detect languages, frameworks, and package manager[G]Generate - Generate copilot-instructions.md using Copilot SDK[S]Save - Save generated instructions (in preview mode)[D]Discard - Discard generated instructions (in preview mode)[Q]Quit
# Generate instructions for current directory
npx tsx src/index.ts instructions
# Generate for specific repo with custom output
npx tsx src/index.ts instructions --repo /path/to/repo --output ./instructions.md
# Use a specific model
npx tsx src/index.ts instructions --model gpt-5Process multiple repositories across organizations:
# Launch batch TUI
npx tsx src/index.ts batch
# Save results to file
npx tsx src/index.ts batch --output results.jsonBatch TUI Keys:
[Space]Toggle selection[A]Select all repos[Enter]Confirm selection[Y/N]Confirm/cancel processing[Q]Quit
# Analyze current directory
npx tsx src/index.ts analyze
# Analyze specific path with JSON output
npx tsx src/index.ts analyze /path/to/repo --jsonGenerate configuration files for your repo:
# Generate MCP config
npx tsx src/index.ts generate mcp
# Generate VS Code settings
npx tsx src/index.ts generate vscode --force
# Generate custom prompts
npx tsx src/index.ts generate prompts
# Generate agent configs
npx tsx src/index.ts generate agents
# Generate .aiignore file
npx tsx src/index.ts generate aiignoreView available instruction templates:
npx tsx src/index.ts templatesView and manage Primer configuration:
npx tsx src/index.ts configCheck for and apply updates:
npx tsx src/index.ts updateAutomatically create a PR to add Primer configs to a repository:
# Create PR for a GitHub repo
npx tsx src/index.ts pr owner/repo-name
# Use custom branch name
npx tsx src/index.ts pr owner/repo-name --branch primer/custom-branchTest how well your instructions improve AI responses:
# Create a starter eval config
npx tsx src/index.ts eval --init
# Run evaluation
npx tsx src/index.ts eval primer.eval.json --repo /path/to/repo
# Save results and use specific models
npx tsx src/index.ts eval --output results.json --model gpt-5 --judge-model gpt-5Example primer.eval.json:
{
"instructionFile": ".github/copilot-instructions.md",
"cases": [
{
"id": "project-overview",
"prompt": "Summarize what this project does and list the main entry points.",
"expectation": "Should mention the primary purpose and key files/directories."
}
]
}-
Analysis - Scans the repository for:
- Language files (
.ts,.js,.py,.go, etc.) - Framework indicators (
package.json,tsconfig.json, etc.) - Package manager lock files
- Language files (
-
Generation - Uses the Copilot SDK to:
- Start a Copilot CLI session
- Let the AI agent explore your codebase using tools (
glob,view,grep) - Generate concise, project-specific instructions
-
Batch Processing - For multiple repos:
- Select organizations and repositories via TUI
- Clone, branch, generate, commit, push, and create PRs
- Track success/failure for each repository
-
Evaluation - Measure instruction quality:
- Run prompts with and without instructions
- Use a judge model to score responses
- Generate comparison reports
primer/
├── src/
│ ├── index.ts # Entry point
│ ├── cli.ts # Commander CLI setup
│ ├── commands/ # CLI commands
│ │ ├── analyze.ts # Repository analysis
│ │ ├── batch.tsx # Batch processing
│ │ ├── config.ts # Config management
│ │ ├── eval.ts # Evaluation framework
│ │ ├── generate.ts # Config generation
│ │ ├── init.ts # Interactive setup
│ │ ├── instructions.tsx # Instructions generation
│ │ ├── pr.ts # PR creation
│ │ ├── templates.ts # Template management
│ │ ├── tui.tsx # TUI launcher
│ │ └── update.ts # Update command
│ ├── services/ # Core business logic
│ │ ├── analyzer.ts # Repository analysis
│ │ ├── evaluator.ts # Eval runner
│ │ ├── generator.ts # Config generation
│ │ ├── git.ts # Git operations
│ │ ├── github.ts # GitHub API
│ │ └── instructions.ts # Copilot SDK integration
│ ├── ui/ # Terminal UI
│ │ ├── AnimatedBanner.tsx
│ │ ├── BatchTui.tsx # Batch processing UI
│ │ └── tui.tsx # Main TUI
│ └── utils/ # Helpers
│ ├── fs.ts
│ └── logger.ts
├── package.json
├── tsconfig.json
├── primer.eval.json # Example eval config
└── PLAN.md # Project roadmap
# Type check
npx tsc -p tsconfig.json --noEmit
# Run in dev mode
npx tsx src/index.tsInstall the GitHub Copilot Chat extension in VS Code. The CLI is bundled with it.
Run copilot in your terminal, then type /login to authenticate.
Install GitHub CLI and authenticate: brew install gh && gh auth login
Or set a token: export GITHUB_TOKEN=<your-token>
- Ensure you're authenticated with the Copilot CLI
- Check your network connection
- Try a smaller repository first
MIT
