Article

How do I use Copilot to write code?


Key concepts

Before talking about workflows or tricks, there are concepts you need to master if you're going to work with AI agents. These concepts separate someone who gets poor-quality results from someone who consistently gets good ones.


Context

Context is all the information the agent has available to understand you and produce something useful. I divide it into two types: static and dynamic.

Static context

This is everything that is always loaded from the start of the conversation. The agent already has it before you write a single word.

In Copilot, static context artifacts include:

  • AGENTS.md — Workspace-level instructions the agent reads automatically.
  • copilot-instructions.md — Global Copilot instructions that apply to all conversations.
  • instructions.md — Additional instructions that can be modularized by folder or purpose.
  • Agent files (previously called chat modes) — Custom agent definitions that include their own system text.

Think of this as the agent's "base memory": it tells the agent who it is, what rules to follow, and how to behave in your project.

Dynamic context

This is everything the agent discovers on its own as it works. It isn't predefined. The agent acquires it as the task progresses.

Examples:

  • Source code the agent reads while searching the workspace.
  • Additional instruction files it discovers while navigating folders, such as instructions.md files with specific applyTo values.
  • Nested AGENTS.md files in project subfolders that the agent encounters while exploring the structure.
  • Search results, build errors, terminal output, and any other artifacts the agent consults during the session.
  • SKILLS and MCPs, which I'll explain later.

Skills

Skills are relatively new and gained popularity very quickly because they make it easy to share context between projects and agents.

For me, skills completely changed the way I work with AI agents. When I started writing this article, skills didn't exist yet. A month later, they were defining how code is developed with AI.

A skill is a SKILL.md file that encapsulates domain knowledge, best practices, and proven workflows for a specific area, such as testing, technical design, performance, or API design.

Before skills, each project had to reinvent its instructions from scratch. Skills solve that problem: they're portable and reusable. You write the knowledge once and apply it in any project or agent.

Especially outside GitHub Copilot, where instructions.md files didn't exist, people were looking for a way to share knowledge between projects and agents.

The good thing is that skills are a universal standard similar to AGENTS.md, so you can use them in whichever agent you prefer: Claude Code, OpenCode, GitHub Copilot, and so on.

In Copilot Chat, support for skills moved from experimental to stable relatively shortly before this article was written.

How to install skills

There are several ways to add skills to your project:

1. Manual — Copy the SKILL.md file directly into your project's skills folder, for example .copilot/skills/my-skill/SKILL.md. It always works, with no dependencies.

2. Vercel CLI (skills.sh) — Vercel created an open skills ecosystem with a CLI that installs them with a single command:

npx skills add vercel-labs/agent-skills

The CLI downloads the skill files from GitHub and configures them automatically for your agent.

3. Context7 CLI — Context7 also offers a catalog of installable skills:

npx ctx7 skills install <owner/repo>

Examples of skills

Skill Source What it does
vercel-react-best-practices vercel-labs/agent-skills More than 40 performance rules for React/Next.js, prioritized by impact.
web-design-guidelines vercel-labs/agent-skills Audits your UI against more than 100 accessibility, performance, and UX rules.

How to activate skills predictably

The agent activates a skill automatically when it detects that your task matches its domain. You don't need to invoke it manually.

When I started using skills, I noticed other people reporting an experience similar to mine: sometimes the skill didn't activate or the agent didn't seem to use it. VS Code even offers a Use Skill Adherence Prompt setting to make the agent use skills more predictably. Over time this has become less common, I suppose because of skill adoption and tool updates.

One tip or good practice to make sure this doesn't happen is to be very obvious and clear about when a skill should activate in its metadata header. Think of that header as the only thing the agent has to decide whether the skill applies to the task.

---
name: technical-design-writer
description: |
  Use when the user explicitly asks to:
  - Create, write, or draft a "tech design", "technical design", "diseño técnico", or "technical design document"
  - Document a system design, architecture proposal, or implementation plan using a formal template
  - Follow a standard format for technical decisions with APIs, data models, and operational impact

  DO NOT use for: specs, ADRs only, slide presentations, diagrams only, or informal technical notes.

  This skill enforces a mandatory Markdown template with sections for: Summary, Context, Options, Detailed Design (APIs, data, code, PoC), Metrics, and Consequences.
compatibility: opencode
---

MCPs (Model Context Protocol)

MCPs have been around in the ecosystem longer than skills, and they're also part of dynamic context. The difference: skills give the agent knowledge, while MCPs give it capabilities. With an MCP, the agent can do things and consult external sources it otherwise couldn't reach.

An MCP is an open standard that connects AI agents to external tools and services through a uniform protocol. In practice, an MCP server exposes tools that the agent invokes directly: searching documentation, creating issues, querying APIs, interacting with databases, and so on.

Without MCPs, an agent can only read files and run terminal commands. With MCPs, its reach multiplies:

  • Access to up-to-date documentation instead of relying on training data that may be outdated.
  • Interaction with external services such as Jira, GitHub, Confluence, databases, and proprietary APIs.
  • Workflow automation: create issues, open PRs, publish pages, all from chat.

MCP examples

MCP What it enables Example
Context7 Up-to-date documentation for 69,000+ libraries injected directly into the prompt. Eliminates hallucinations of nonexistent APIs. Create a middleware in Next.js 14 to validate a JWT. use context7
Atlassian Creates/edits Jira issues, publishes in Confluence, searches with JQL, without leaving the editor. Create an issue in INS titled "Fix timeout in RFQ"
GitHub Manages repositories, issues, PRs, and branches from the agent. Open a PR with the changes from this session
Fetch Reads arbitrary web pages for research or extracting information. Research the Stripe API on its docs page

[!tip] Skills vs MCPs

Skills MCPs
Give the agent Knowledge Capabilities
Activate When the task matches their domain When the agent needs an external tool
Example "Use this pattern for tests" "Query the Jira API"
Format SKILL.md file in the repo External MCP server

Instructions

Copilot instruction files are Markdown files (.instructions.md) you add to your project to share knowledge between agents and programming modes. They resemble skills conceptually, but they affect context in a very different way.

When I started with Copilot, instructions were my main tool. I filled files with coding conventions, preferred patterns, linting rules, everything I wanted the agent to "know" beforehand. And they worked well for establishing a baseline.

But over time, especially when skills arrived, instructions began to make less sense to me. Skills offer the same thing in a more modular and portable way. Most importantly, they activate only when they apply instead of always being loaded. (Obviously, depending on applyTo.)

Instructions don't scale

You can have multiple instruction files, each with an applyTo that defines which files it applies to. The problem appears when:

  1. Files are too long — Dozens of rules, conventions, and examples.
  2. They apply to everything — Using applyTo: "**" injects them into every conversation, regardless of context.
  3. They accumulate — Several broadly scoped files add up to hundreds or thousands of tokens before you've written a single word.

What should work as dynamic context becomes static context. Always present, whether it takes up space or not.

The context window is finite. Every token you spend on instructions is one less token for:

  • Reading your source code.
  • Analyzing errors.
  • Reasoning about the task.
  • Generating a quality response.

If you saturate the context with generic instructions, the agent loses attention on what really matters: your current task. More instructions, less quality.

How I use them

My use of instruction files is almost minimal. A few bullet points, just to adjust little things the AI repeatedly does oddly or incorrectly. If I notice an annoying pattern, I add a single bullet point to correct it and don't add more context there. The idea is to make minimal corrections, not style manuals.

One impressive thing about skills is that you can distribute them alongside other context artifacts the agent can use: small code snippets, more Markdown documents, and so on. A notable example is vercel-labs/react-native-skills, which is a single skill distributed with another folder of Markdown files serving as individual rules the agent can consult without loading them all into context.


Context window

The context window is the maximum number of tokens a model can process in a single conversation. This includes everything: system instructions, files read, your prompt, and the response generated. The window changes depending on the model you use. For example, Claude Opus 4.6 in GitHub Copilot has 128K tokens.

Everything we've discussed (static and dynamic context, skills, MCPs, instructions) competes for space within this same window. If you quickly fill it with generic instructions or long conversations, the model has less space to think about what you're asking it to do.

The 60–70% rule

There is an informal consensus among programmers who work with AI agents: it's best to use at most 60–70% of the context window before opening a new chat. Beyond that point, quality degrades. The model starts to "forget" early context, loses precision, and generates more generic answers.

[!example] Example: Claude Opus 4.6 (128K tokens)

Range Tokens State
0–40% 0–51K Optimal zone. The model has plenty of room to reason.
40–70% 51–90K Functional zone. Quality remains, but it starts to cost more.
70–100% 90–128K Risk zone. Open a new chat.

Auto-compaction

Tools like Copilot and OpenCode already have mechanisms that automatically compact context as the conversation approaches the limit. The agent summarizes or discards earlier parts to free space and keep working. It's useful, but it isn't magic. Compaction loses detail, so it's unwise to depend on it as your main strategy.


Vibe Coding vs Spec Driven

Originally, vibe coding as I understand it is a development workflow based on your AI tool's default Agent Build as the first and only step. As ideas come up, you use Build mode to develop code.

This works well. But it can lead to disorder. Remember, context is king: if you have good skills, good prompts, and just the right instruction files, vibe coding works very well for projects in general.

Collaborative projects are where friction begins. However, the next natural step toward order is the Plan Mode → Agent Mode pattern.

We've all come to the conclusion that bouncing ideas off AI sometimes leads you to solve the problem yourself. The rubber ducky effect.

Now, for standardized, scalable, consistent development, there is Spec Driven Development. There are many approaches you can take, from using only Plan Mode and saving it to a Markdown file (Claude Code even added functionality to track your tasks in .md files), to using complete frameworks like github/spec-kit or bmad.

My current approach

My way of doing Spec Driven development is through an agent I customized myself. A few lines of instructions in an agent help me create .md files in a tasks/ folder, similar to what Claude Code does. For now, it's enough for me.

I bounce ideas off my "task-builder" agent, using code references that improve the quality of the plan, and finally save it in a text .md file that helps me track the progress of my activities.

It literally looks like a TODO list that the agent itself checks off:

# TASK-042: Migrate notification service to serverless architecture

## Context

The current notification service runs in a dedicated ECS task.
We want to move it to Lambda + SQS to reduce costs and simplify deployment.

## Tasks

- [x] Define the SQS event schema for each notification type
- [x] Create Lambda handler with dead-letter queue
- [x] Migrate email templates to S3
- [ ] Implement retry policy with exponential backoff
- [ ] Add CloudWatch metrics by notification type
- [ ] Update integration tests
- [ ] Cleanup: remove old ECS task definition and security groups

## Notes

- The infrastructure team confirmed that the Lambda concurrency limit is 500.
- Current templates use Handlebars and remain unchanged.

Once my tasks file is written using Opus 4.6, saved, and committed, I delegate implementation to Codex 5.3.

When it's done, I return to Opus 4.6 and ask a simple question: audit whether the task is really complete or whether it detects drift in the implementation.

If all goes well, I make the final commit with the implemented changes and delete the tasks file. To me, task files are disposable: they serve their purpose during development, and afterward I no longer need them.

The workflow looks like this:

Spec-driven workflow with agents

Long-term memories

Another piece of my Spec Driven Development is long-term memory. Tools like spec-kit generate files called constitucion.md where you document the project's pillars, and every generated task must satisfy them.

I don't use all of spec-kit, only some parts. What I like for now is that it can be a technique for gradual adoption, because the learning curve of the full framework can be overwhelming.

In my case, with my teams, the cycle works like this: every time a tasks document is completed (the documents come from Jira user stories), I try to use another agent called "memory-writer" to update the project's technical or architecture documentation. I also use Opus 4.6 for that documentation.

The complete development cycle then looks like this:

Spec-driven development lifecycle with agents

I know there's a Claude Code plugin that maintains long-term memory. I haven't yet implemented anything to do RAG over my memories, but I think an MCP that provides a Vector DB could help me extract specific information without loading the entire document into context.

And here again, context is king.

[!abstract] Tasks vs Memory

Tasks Memory
Lifecycle Created, executed, deleted Lives with the project
Mutability Immutable (checked off, not edited) Mutable (evolves with each iteration)
Persistence Disposable, backed by Git history Persistent in the repository
Example TASK-042.md arquitectura.md, decisions.md

Multi-agent techniques

At this point we've established the foundations and rules of the game. Thanks to specs, we can distribute work that isn't interdependent. Task files must be executable with as little dependence on one another as possible. If you achieve that, you can scale the workflow.

GitHub Copilot offers the ability to run agents both in the cloud and in the background, working in different worktrees. If our tasks are independent, we can ask Copilot to work on different branches and send us a PR when it finishes so we can review, approve, reject, or integrate it.

This same technique is integrated into tools like OpenAI's Codex and open-source tools like Conductor or OpenCode UI.

But it's also something you can do yourself with a few commands and custom agent instructions. These tools simply provide better UIs for these new ways of working.

Multi-agent workflow with worktrees

Going deeper into multi-agent patterns

Ever since Anthropic's article on how they disrupted an AI espionage operation, I've tried to learn and improve my autonomous multi-agent development techniques. In another article focused on its multi-agent research system, Anthropic shows some concrete patterns for this kind of development.

Anthropic describes a pattern in which a LeadResearcher orchestrates specialized subagents, each with its own execution context, shared memory, and an iterative research cycle:

Anthropic multi-agent research system

Workers: functional subagents

For now, my stack looks like this. I usually have "worker" subagents in charge of functional tasks that don't require more context or research: running tests, extracting console output, executing scripts.

These subagents help save the main agent's context because each creates its own execution context. The worker does its job, returns the result, and the main agent doesn't spend tokens on all that intermediate execution.

Pipelines: high-level orchestration

I also have high-level agents in charge of orchestration. For example, a pipeline like:

Challenger → Coder → Refactorer → Reviewer

It's a TDD workflow oriented toward agents. The Challenger writes the tests or defines the criteria, the Coder implements, the Refactorer cleans up, and the Reviewer audits.

Routers: domain specialization

You can also have router models: a Coder that routes to different subagents or skills depending on the type of task. If you want it to take on the archetype of an FE developer, React developer, QA, Tester, and so on, subagents create specific execution contexts that make them specialists in a subject.

Multi-agent router pattern

Competing Solutions

Another pattern I like is to open multiple subagents that implement the same solution using different models or approaches, and at the end have a reviewer choose the best one. It's like holding a contest between agents: each attacks the problem from its own angle, and the final reviewer compares the results and picks the best.

Competing solutions pattern

Agents as pipelines

I now see my custom agents more as pipelines, as if they were CI/CD. They're pipelines for orchestrating workflows, and skills, memory, and tasks are everything that makes them rich in context.


Conclusion

Since Copilot, GPT-3, and company appeared, workflows have evolved in a direction that, for me, comes down to this: how to stop copying and pasting with the model and instead let the model get as close as possible to what we want it to achieve. Today, with skills, MCPs, specs, memories, and multi-agent pipelines, that distance is getting shorter.

But the curious thing is that writing code with AI agents increasingly resembles simply writing good code. The same longstanding best practices still rule: modular, reusable, documented, tested code. What changed is who executes them and how fast.

In the end, AI only got engineers to finally write their tests and documentation, break their train of thought into clear steps, and put all of that into a resource anyone can understand.

What a surprise, right?