Copilot Forgets Everything. Make It Stop.

dev.to

You open a new Copilot chat and explain everything again.

Your stack. Folder structure. That “no default exports” rule.

Copilot writes code, but forgets context.

This isn’t a bug though. LLMs are stateless, every chat starts fresh.

The good part? You can fix it.


The Problem Has a Name

You’re dealing with three problems:

  • The Blank Slate: Every session starts from zero.

  • Correction Amnesia: You fix a mistake. Next session, same mistake.

  • Standards Drift: Your team has patterns. Copilot ignores them. Code becomes inconsistent.

Each problem has a different fix. Let's go through them one by one.


The Instructions File (Your Copilot Brief)

Create this file:

your-project/
└── .github/
    └── copilot-instructions.md
Enter fullscreen mode Exit fullscreen mode

Copilot reads it at the start of every chat. No setup.

Think of it as your team’s “how we work” doc.

Example:

## Stack
- React 18, TypeScript (strict), Tailwind CSS
- Node.js + Express + Prisma + PostgreSQL
- Testing: Vitest + React Testing Library
- Package manager: pnpm only

## Rules
- Named exports only — no default exports
- No `any` types
- Every API route uses `authenticate`
- Handle nulls explicitly — no optional chaining on Prisma results
- Conventional Commits: feat(scope): message
Enter fullscreen mode Exit fullscreen mode

Now everyone gets the same baseline.


Scoped Rules (Right Rules, Right Files)

One file works… until it grows.

Frontend, backend, and tests follow different rules. A single file mixes context.

Use scoped files:

.github/
├── copilot-instructions.md
└── instructions/
    ├── frontend.instructions.md
    ├── backend.instructions.md
    └── testing.instructions.md
Enter fullscreen mode Exit fullscreen mode

Each file defines where it applies:

---
applyTo: "src/components/**/*.tsx"
---

## Component Rules
- Functional components only
- Props interface named `[ComponentName]Props`
- Use `cn()` for conditional classes
- No inline styles
Enter fullscreen mode Exit fullscreen mode

Now Copilot gets relevant rules only.


The Memory Tool (Fix Repeated Mistakes)

Copilot has a memory tool in VS Code (preview, enabled by default).

When you correct it, make it persistent:

Remember: never use optional chaining on Prisma query results. 
Always handle null with an explicit if-check.
Enter fullscreen mode Exit fullscreen mode

It stores this and applies it in future sessions.

Memory types:

User memory (all projects)

Remember I prefer async/await over .then()
Enter fullscreen mode Exit fullscreen mode

Repository memory (this project)

Remember we use App Router (March 2026)
Remember UserAvatar breaks in Server Components
Enter fullscreen mode Exit fullscreen mode

Session memory (current chat only)

Key habit: When you fix a repeated mistake, tell it to remember.

Check memory with Chat: Show Memory Files.

Note: Memory tool is in preview, enable via github.copilot.chat.tools.memory.enabled.


Prompt Files (Stop Repeating Yourself)

If you repeat prompts, create a prompt file:

.github/prompts/code-review.prompt.md
Enter fullscreen mode Exit fullscreen mode

Use it with /code-review.

Example:

---
name: "code-review"
description: "Reviewstagedchanges"
mode: "ask"
---

Review staged changes.

Flag:
- Must Fix — bugs, auth, unsafe types
- Should Fix — standards, missing tests
- Suggestion — improvements

Reference [copilot-instructions.md](../copilot-instructions.md).
Enter fullscreen mode Exit fullscreen mode

Now your team shares the same workflow.

Other useful prompts:

  • /new-component
  • /new-migration
  • /write-tests

The Full Picture

.github/
├── copilot-instructions.md
├── instructions/
│   ├── frontend.instructions.md
│   ├── backend.instructions.md
│   └── testing.instructions.md
└── prompts/
    ├── code-review.prompt.md
    ├── new-component.prompt.md
    └── new-migration.prompt.md
Enter fullscreen mode Exit fullscreen mode

Plus memory running in the background.

Problem Fix
Blank slate copilot-instructions.md
Wrong rules Scoped files
Repeated mistakes Memory tool
Repeated prompts Prompt files

Just Start With One Thing

You don’t need everything today.

Start with copilot-instructions.md. Add your stack and a few rules. Commit it. See the difference.

Then:

  • Add scoped files when needed
  • Save repeated fixes to memory
  • Create prompt files when repetition appears

The model won’t change. But your context can improve every week.

Source: dev.to

arrow_back Back to News