Skip to content

Repository Onboarding: The Golden Prompt from GitHub Docs

advanced 25 min 📋 Copy-paste ready
Sources not yet verified
copilotinstructionsonboardingconfigurationadvanced

Scenario

Context: You're onboarding a repository to GitHub Copilot coding agent by creating a .github/copilot-instructions.md file

Goal: Create comprehensive repository instructions that minimize agent exploration time and reduce CI failures

Anti-pattern: Writing vague, incomplete, or task-specific instructions that require the agent to explore via grep/find

Tools: GitHub Copilot AgentClaude CodeCursor

Conversation

The Golden Prompt

This prompt comes directly from GitHub's official documentation. It's designed for a one-time comprehensive repository onboarding that pays dividends on every future AI interaction.

👤 You

Your task is to "onboard" this repository to Copilot coding agent by adding a .github/copilot-instructions.md file in the repository that contains information describing how a coding agent seeing it for the first time can work most efficiently.

You will do this task only one time per repository and doing a good job can SIGNIFICANTLY improve the quality of the agent's work, so take your time, think carefully, and search thoroughly before writing the instructions.

Goals

  • Reduce the likelihood of a coding agent pull request getting rejected by the user due to generating code that fails the continuous integration build, fails a validation pipeline, or having misbehavior.
  • Minimize bash command and build failures.
  • Allow the agent to complete its task more quickly by minimizing the need for exploration using grep, find, str_replace_editor, and code search tools.

Limitations

  • Instructions must be no longer than 2 pages.
  • Instructions must not be task specific.

What To Add

High Level Details

Add the following high level details about the codebase to reduce the amount of searching the agent has to do to understand the codebase each time:

  • A summary of what the repository does.
  • High level repository information, such as the size of the repo, the type of the project, the languages, frameworks, or target runtimes in use.

Build Instructions

Add information about how to build and validate changes so the agent does not need to search and find it each time:

  • For each of bootstrap, build, test, run, lint, and any other scripted step, document the sequence of steps to take to run it successfully as well as the versions of any runtime or build tools used.
  • Each command should be validated by running it to ensure that it works correctly as well as any preconditions and postconditions.
  • Try cleaning the repo and environment and running commands in different orders and document errors and misbehavior observed as well as any steps used to mitigate the problem.
  • Run the tests and document the order of steps required to run the tests.
  • Make a change to the codebase. Document any unexpected build issues as well as the workarounds.
  • Document environment setup steps that seem optional but that you have validated are actually required.
  • Document the time required for commands that failed due to timing out.
  • When you find a sequence of commands that work for a particular purpose, document them in detail.
  • Use language to indicate when something should always be done. For example: "always run npm install before building".
  • Record any validation steps from documentation.

Project Layout

List key facts about the layout and architecture of the codebase to help the agent find where to make changes with minimal searching:

  • A description of the major architectural elements of the project, including the relative paths to the main project files, the location of configuration files for linting, compilation, testing, and preferences.
  • A description of the checks run prior to check in, including any GitHub workflows, continuous integration builds, or other validation pipelines.
  • Document the steps so that the agent can replicate these itself.
  • Any explicit validation steps that the agent can consider to have further confidence in its changes.
  • Dependencies that aren't obvious from the layout or file structure.
  • Finally, fill in any remaining space with detailed lists of the following, in order of priority: the list of files in the repo root, the contents of the README, the contents of any key source files, the list of files in the next level down of directories, giving priority to the more structurally important and snippets of code from key source files, such as the one containing the main method.

Steps To Follow

  • Perform a comprehensive inventory of the codebase. Search for and view:
    • README.md, CONTRIBUTING.md, and all other documentation files.
    • Search the codebase for build steps and indications of workarounds like 'HACK', 'TODO', etc.
    • All scripts, particularly those pertaining to build and repo or environment setup.
    • All build and actions pipelines.
    • All project files.
    • All configuration and linting files.
  • For each file:
    • think: are the contents or the existence of the file information that the coding agent will need to implement, build, test, validate, or demo a code change?
    • If yes:
      • Document the command or information in detail.
      • Explicitly indicate which commands work and which do not and the order in which commands should be run.
      • Document any errors encountered as well as the steps taken to workaround them.
  • Document any other steps or information that the agent can use to reduce time spent exploring or trying and failing to run bash commands.
  • Finally, explicitly instruct the agent to trust the instructions and only perform a search if the information in the instructions is incomplete or found to be in error.
This is the EXACT golden prompt from GitHub's official documentation. It's comprehensive, structured, and designed to maximize agent efficiency on every future interaction with the repo.

Why This Prompt Works

This prompt succeeds because it's structured around elimination of agent exploration. Let's break down the key principles:

🤖 AI

This is an excellent prompt for repository onboarding. Let me highlight what makes it effective:

1. Clear Goals (Not Vague)
Instead of "help the AI understand the codebase," it specifies:

  • Reduce CI failures
  • Minimize command failures
  • Eliminate exploration (grep, find, code search)

2. Constraints Create Focus

  • 2 pages max → forces prioritization
  • Not task-specific → ensures reusability

3. Validated Commands, Not Documentation
The prompt requires:

  • Actually running each command
  • Testing from a clean state
  • Documenting what fails and why
  • Including timing for timeout detection

4. Architecture As Navigation
Instead of just listing files, it asks for:

  • Relative paths to key files
  • Config file locations
  • Pre-commit check order
  • Non-obvious dependencies

5. Ends With Trust Instruction
"Explicitly instruct the agent to trust the instructions and only perform a search if the information is incomplete or in error."

This single line prevents the agent from redundantly exploring what's already documented.

The assistant identifies the five principles that make this prompt effective: clear goals, constraints, validation, navigation, and trust.

Applying the Prompt

Here's how an agent would execute this prompt on a typical repository:

🤖 AI

Let me execute this prompt on your repository. I'll follow the steps systematically:

Step 1: Comprehensive Inventory

# Documentation
find . -name "*.md" -type f | head -20
cat README.md
cat CONTRIBUTING.md 2>/dev/null || echo "No CONTRIBUTING.md"

# Build scripts
cat package.json | jq '.scripts'
ls -la scripts/ 2>/dev/null
cat Makefile 2>/dev/null

# CI/CD pipelines
ls -la .github/workflows/
cat .github/workflows/*.yml

# Config files
ls -la *.json *.yaml *.toml 2>/dev/null
cat tsconfig.json biome.json .eslintrc* 2>/dev/null

# Workarounds
grep -r "HACK\|TODO\|FIXME\|WORKAROUND" --include="*.ts" --include="*.js" | head -10

Step 2: Validate Commands From Clean State

# Clean environment
rm -rf node_modules dist build .cache

# Attempt build without install (document failure)
npm run build  # ❌ Expected to fail

# Proper sequence
npm install    # ✅ ~45 seconds
npm run build  # ✅ ~3 seconds
npm run test   # ✅ ~5 seconds, 157 tests
npm run lint   # ✅ biome check passes

Step 3: Document the Architecture

I've gathered enough information to write the instructions file...

The agent follows the prompt's steps systematically: inventory, validation, then documentation.

The Output: A Complete Instructions File

Here's what the agent produces after following the golden prompt:

🤖 AI
# Repository Instructions for AI Agents

## Project Summary
AI Dev Maturity - configuration-driven learning platform built with Astro/Starlight. Teaches AI development concepts through interactive content.

**Tech Stack**: Node.js 20+, TypeScript, Astro 5.x, Zod schemas
**Size**: ~55 pages, 16 concepts, 8 exercises, 9 conversations

## Critical: Command Ordering

**Always run these commands in order:**
```bash
npm install          # REQUIRED first - ~45s
npm run build        # Compiles JSON → build/ - ~3s
cd frontend && npm run build  # Builds Astro - ~30s

⚠️ npm run build without npm install fails with "tsc not found"

Build Commands (from repo root)

Command Purpose Time Notes
npm install Install deps ~45s Always run first
npm run build Compile content ~3s Outputs to build/
npm run test:quick Syntax + unit ~5s 157 tests
npm run validate:all Pre-commit ~20s Run before committing

Directory Layout

/
├── build.js              # Main build script
├── CLAUDE.md             # Project documentation
├── dimensions/           # Survey dimension JSON
├── concepts/             # AI concept definitions
├── exercises/            # Hands-on exercises
├── content/conversations/# Simulated conversations
├── sources/              # Citation sources
├── schema/               # JSON Schema definitions
├── frontend/
│   ├── src/components/   # Astro components
│   ├── src/schemas/      # Zod type definitions
│   └── src/content/docs/ # MDX pages
└── lib/                  # Build utilities

Pre-commit Checks (CI runs these)

  1. npx biome check - Linting
  2. npx tsc --noEmit - Type checking
  3. npm run build -- --validate - Build validation
  4. File size check - >500 lines fails

Architecture Principles

  • All content is JSON - Never hardcode content
  • Every claim needs a source - Add to sources/*.json
  • Zod schemas define types - See frontend/src/schemas/

Common Errors

Error Cause Fix
"tsc not found" Missing deps npm install
"Source X not found" Missing citation Add to sources/*.json
"File exceeds 500 lines" Pre-commit hook Split file

Trust these instructions. Only search if incomplete or in error.
```

The output follows the golden prompt's structure: summary, commands with timing, layout, checks, errors, and the trust instruction.

Key Insight

The difference between good and bad repository instructions is validated commands vs copied documentation. The golden prompt forces you to actually run every command and document what happens.

Key Takeaways

  • This prompt is directly from GitHub's official documentation for Copilot agent onboarding
  • The key goals are: reduce CI failures, minimize command failures, eliminate exploration
  • Commands must be validated by actually running them, not copied from docs
  • Include timing estimates so agents can detect timeouts
  • End with 'Trust these instructions. Only search if incomplete or in error.'

Try It Yourself

Prompt Template

Copy the golden prompt above and run it on your repository. The agent will:
1. Inventory all documentation, scripts, configs, and pipelines
2. Validate each command from a clean state
3. Document errors and workarounds
4. Generate a comprehensive copilot-instructions.md

This is a one-time investment that improves every future AI interaction.

Variations to Try

  • Add path-specific instructions in .github/instructions/ for different parts of the codebase
  • Create AGENTS.md with agent-specific behavior rules
  • Include a 'Making Changes' section for your specific architecture

Sources

Tempered AI Forged Through Practice, Not Hype

Keyboard Shortcuts

j
Next page
k
Previous page
h
Section home
/
Search
?
Show shortcuts
m
Toggle sidebar
Esc
Close modal
Shift+R
Reset all progress
? Keyboard shortcuts