CopilotForgeDraft

Catalogue › Copilot Code › repository-context

Repository context

Prepares the repository context an AI coding agent works within - custom instructions, conventions, architecture notes, approved dependencies, protected areas, test commands and never-touch rules - so generated changes follow the organisation's standards. Use when a repository is first opened to a coding agent, when agent output keeps ignoring conventions, or when a team asks how to stop the agent touching secrets or sensitive code.

Department
Copilot Code
Lifecycle
Mobilise, Deliver, Improve
Maturity
builder, scaler, ai-enterprise
Risk tiers
1, 2, 3, 4
Platforms
copilot-code, github, azure, entra
Editions
starter, scale, enterprise
Reviewers
security-privacy
Status
draft
Copilot Cowork
Copilot Code plugin for Copilot Cowork, or this skill on its own: Download SKILL.md
Licence
CC BY 4.0, by Simon Foote

Purpose

An AI coding agent reads what is in front of it: the code, the files it is pointed at and the instructions it is given. If the repository does not state its conventions, approved libraries, architecture and boundaries, the agent follows its own defaults and whatever patterns it happens to find, including the bad ones. This skill prepares the repository so the agent works within the organisation's standards: clear instructions, conventions, a short architecture note, approved dependencies, protected areas, how to build and test, and what must never be touched or committed. It goes wrong when context is a long, generic document the agent and engineers both ignore, or when protection relies on asking the agent nicely rather than on repository controls.

When to use

When not to use

Questions to ask first

  1. What conventions, patterns and libraries should every change follow, and where are they written down today?
  2. Which parts of the repository are sensitive (authentication, authorisation, payment, data access, infrastructure, pipelines) and need stricter review?
  3. Where do secrets and environment configuration live, and how are they kept out of the repository?
  4. How does someone build, run and test the code locally, in commands the agent can follow?
  5. What can the agent's identity actually do in the repository and connected systems, and is that the least it needs?

Required inputs

If engineering standards do not exist, write the minimum the repository needs and route the gap to ai-engineering:ai-engineering-standards. Never put secrets, credentials or real personal data into repository context.

Decision framework

Use instructions for guidance and repository controls for protection.

NeedPut it in instructionsEnforce it with controls
Conventions, patterns, namingYes, concise with pointers to examplesLinters and formatters in the pipeline
Approved dependenciesYes, list and rule for adding new onesDependency review and scanning in the pipeline
Protected areasYes, name them and say they need an engineerCode owners and required reviews on those paths
Secrets and configurationYes, say where they live and never to add themSecret scanning, push protection, no secrets in the repository
Build and test commandsYes, exact commandsPipeline runs the same commands on every change
Agent permissionsNot applicableLeast-privilege identity, branch protection, no direct pushes to the main branch

Rule: anything whose failure would be a security or data incident must be enforced by a control, not only stated in an instruction. Instructions shape behaviour; controls prevent harm.

Practitioner approach

Start by reading the repository as the agent would. Is there a clear statement of what the software does, how it is structured, how to build and test it, and which patterns to follow? Most repositories rely on tribal knowledge that the agent cannot reach. Write a short architecture note: the main components, how data flows, where the boundaries are, and the one or two patterns new code should copy. Point to real examples in the codebase rather than describing patterns in the abstract.

Write the custom instructions concisely. State the conventions that matter, the approved libraries and how to propose a new one, the commands to build and test, the rule that tests accompany every change, and the areas that require an engineer. Keep them to what the agent and a new engineer genuinely need; long instructions dilute the important rules. Store them in the repository, version them, and review them when standards change. Confirm the current mechanism for repository-level instructions from the relevant source records, because it evolves.

Mark protected areas both ways. Name them in the instructions so the agent knows to avoid or flag them, and enforce them with code owners and required reviews so changes there cannot merge without the right engineer. Typical protected areas are authentication, authorisation, data access layers, payment logic, infrastructure definitions and pipeline files.

Keep secrets out completely. Secrets and environment-specific configuration belong in a secrets store and pipeline variables, never in the repository, examples or instructions. Turn on secret scanning and push protection. Assume that anything the agent can read might appear in a change or a log.

Give the agent the least privilege it needs. It should work on branches, open pull requests and run tests, not push to the main branch, change pipeline definitions or reach production systems. Check what its identity can actually do, not just what the instructions say.

Make the pipeline the backstop. Linting, formatting, dependency review, security scanning and tests should run on every change, so a convention the agent ignored is caught automatically. Then watch the first few agent pull requests closely: where they go wrong, improve the context or the controls, not just the individual change.

Outputs

Microsoft platform considerations

Repository hosting, coding agents, custom instruction files, code owners, secret scanning and pipeline features are provided by the organisation's development platform (often GitHub) and evolve. Confirm current capabilities from the relevant source records and the organisation's platform team rather than relying on memory. Use Microsoft Entra and managed identities for anything the software or pipelines access in Azure, so no long-lived secrets exist to leak.

Adoption considerations

Engineers adopt agent context when it also helps them. A good architecture note and clear build commands speed up new team members as much as the agent; present the work that way.

Knowledge considerations

Repository context is engineering knowledge. Give it an owner (usually the engineering owner), version it with the code and review it when standards or architecture change, so it does not drift into misleading the agent.

Security and privacy considerations

Protection relies on controls, not instructions. Secret scanning, push protection, code owners on sensitive paths, least-privilege agent identity and branch protection are the minimum. From risk tier 2, the controls checklist goes to the security-privacy reviewer through security-privacy:ai-identity-and-access-review.

Responsible AI considerations

Not applicable as a primary concern, because repository context governs how code is written rather than how the software affects people; responsible AI questions about the software itself are handled in the brief and validation.

Evaluation requirements

Check the context works by reviewing the first few agent pull requests against it: conventions followed, no unapproved dependencies, protected areas untouched or correctly flagged. Record what was fixed in the context as a result.

Value measures

Track at team level the share of agent pull requests that pass pipeline checks first time and the number of review comments about conventions, before and after context is improved. Never use these to assess individual engineers.

Scale notes

Starter

A one-page instructions file, a short architecture note, secret scanning and branch protection are enough for a first repository.

Scale

Provide a standard repository template with instructions, controls and pipeline checks, so every new repository starts with them.

Enterprise

Manage organisation-wide instructions and controls centrally through the development platform, with repositories adding their own specifics, and audit agent permissions across repositories regularly.

Hand-offs

Reviewer gates

From risk tier 2, security-privacy reviews the controls checklist and the coding agent's permissions. Findings are blocking or advisory; secrets in the repository or an agent able to push to the main branch are blocking.

Failure modes

Sources

references/sources.md in this skill lists the source records behind this skill, what each is authoritative for, how volatile it is and what you may do with it. Product availability, licensing, limits and preview status change often, so check the current source before stating them, and cite what you used.

Never

Source records for this skill

NIST AI Risk Management Framework

Credit

This skill was created by Simon Foote as part of CopilotForge, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Credit the author when you share or adapt it.