# How to give VS Code better memory

VS Code [custom instructions](https://www.knowman.io/guides/give-your-ai-context) keep guidance across sessions in Markdown files that can be shared through source control ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). They guide the model, and they do not guarantee compliance or replace tests, code review, or security controls ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). The selected agent harness determines which instruction files VS Code reads ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## What VS Code keeps across sessions

Custom instructions give an agent reusable guidance about your project, such as where to add code, which libraries to use, and which tests to run ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). The guidance lives in Markdown files, so it persists across sessions and can be shared through source control ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## Create project instructions

Open the Command Palette, open the Agent Customizations editor, and select the Instructions tab ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). When you add workspace instructions, the editor creates or opens the project instruction file offered for your harness ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). No frontmatter is needed for these project instruction files ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

The selected agent harness determines which instruction files VS Code reads ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). AGENTS.md is a cross-agent format, not a file for one harness ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). If your repository already has a project instructions file, open it instead of creating a competing copy ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## Choose scope: personal or shared

VS Code separates scope from activation. Scope determines where guidance is available and who shares it, and activation determines when that guidance is included in a request ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). User-scope instructions hold personal preferences across projects, stored in a location supported by your harness ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). Project instructions sit in the repository and can be shared through source control ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## Choose when instructions activate

With project-wide activation, the harness automatically includes guidance from its project instruction files ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). Targeted `.instructions.md` files use an `applyTo` frontmatter pattern such as `tests/**/*.py` to scope rules to matching files ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). In Local sessions, a description field lets the agent decide by task relevance whether to read an instructions file, separate from pattern matching ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

The Codex harness loads instructions along the path from the repository root down to the session's working directory ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). You can also attach guidance to a single request when automatic discovery or activation is not appropriate ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## Test your instructions and resolve conflicts

Verify instructions in a new chat, so the test does not depend on guidance from the conversation that created them ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). The response's References section, where available, helps check that a file was included, not that the agent complied with it ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

When personal and repository instructions conflict, remove or narrow the conflicting personal rule rather than adding another rule ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). Do not rely on a universal precedence order, because combination rules differ by harness ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

## What instructions will not do

Instructions guide the model. They do not guarantee compliance and do not replace tests, code review, or security controls ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). They do not apply to inline suggestions as you type ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). A link inside an instructions file does not guarantee that the linked document's contents reach the model ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). For a different approach, see [a knowledge base for AI agents](https://www.knowman.io/guides/knowledge-base-for-ai-agents).

## Where KnowMan fits

KnowMan saves articles and links, reads and tags them, [answers questions](https://www.knowman.io/guides/ai-knowledge-base) with citations, and keeps memories: claims, decisions, and playbooks ([KnowMan](https://www.knowman.io/guides/personal-knowledge-base)). Its MCP server is a local [stdio server](https://www.knowman.io/guides/what-is-an-mcp-server), the package `@knowman/mcp`, started with `npx -y @knowman/mcp` on Node 22 or newer (KnowMan). The tools `kb_search`, `kb_ask`, and `kb_memories` give an agent access to [saved reading](https://www.knowman.io/guides/ai-article-saver), cited answers, and remembered decisions and playbooks (KnowMan).

KnowMan's documented client configs cover Claude Desktop, Claude Code, and Cursor (KnowMan). It runs locally with `npx -y @knowman/mcp` and as a hosted server at https://api.knowman.io/mcp, so it can be added to clients that accept remote MCP servers (KnowMan). For more, see [persistent memory for AI agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents).

## Use the hosted KnowMan server

To use KnowMan with VS Code, add the hosted server URL https://api.knowman.io/mcp in a client that supports [remote MCP](https://www.knowman.io/guides/mcp-server-knowledge-base) servers. Sign in with OAuth on the KnowMan consent page, or send an API key as an `Authorization: Bearer <key>` header.

For a local setup instead, run `npx -y @knowman/mcp` and configure it with your preferred MCP client. See the [KnowMan MCP client](https://github.com/Essatt/knowman-mcp) for configuration details.

## Questions

### Does VS Code remember context between sessions?

Custom instructions keep guidance in Markdown files, which persists across sessions and can be shared through source control ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). They guide the model and do not guarantee compliance ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

### How do I add custom instructions in VS Code?

Open the Command Palette, open the Agent Customizations editor, and select the Instructions tab ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). The editor creates or opens the project instruction file offered for your harness, and no frontmatter is needed ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

### Where do custom instructions not apply?

They do not apply to inline suggestions as you type ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). They guide the model and do not replace tests, code review, or security controls ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)).

### Can a VS Code agent use my saved articles and decisions?

Custom instruction files store guidance you write, in Markdown that persists across sessions ([VS Code docs](https://code.visualstudio.com/docs/agent-customization/custom-instructions)). KnowMan's MCP server exposes saved reading and memories through `kb_search`, `kb_ask`, and `kb_memories`, and its documented client configs cover Claude Desktop, Claude Code, and Cursor (KnowMan). For more, see [give your AI context](https://www.knowman.io/guides/give-your-ai-context).

## Related guides

- [Add the KnowMan MCP server to VS Code](https://www.knowman.io/integrations/vscode)

- [How to Give Your AI Context from What You Read](https://www.knowman.io/guides/give-your-ai-context)

- [Persistent Memory for AI Agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents)

- [Connect your knowledge base through KnowMan's MCP server](https://www.knowman.io/guides/mcp-server-knowledge-base)

## More in this topic

- [How to give Windsurf better memory](https://www.knowman.io/guides/windsurf-memory)
- [How to give Roo Code better memory](https://www.knowman.io/guides/roo-code-memory)
- [How to give Augment Code better memory](https://www.knowman.io/guides/augment-memory)

## More for VS Code

- [How to teach VS Code your knowledge](https://www.knowman.io/guides/teach-vscode-your-knowledge)

## A longer memory for your agent

KnowMan keeps your reading, decisions, and playbooks in one place ([KnowMan](/guides/personal-knowledge-base)). Try Pro for 14 days with no credit card ([KnowMan](/guides/second-brain-app)). [Create your account](https://app.knowman.io/signup)

[Start free](https://app.knowman.io/signup)

Every new account starts with 14 days of Pro. No credit card.

Source: https://www.knowman.io/guides/vscode-memory
