Sub topic 1
Why Packaging Instructions Matters: The Context Window
Prerequisites
Assume you can use an AI coding assistant, read Markdown and simple YAML, and use basic Git commands. You should also know that a prompt is an instruction sent to a model.
The Context Window
A context window is the amount of text an agent can consider in one request. It includes your instructions, project files, conversation history, tool results, and the current task. A larger context does not mean unlimited context.
When too much material is loaded, useful instructions may be truncated or receive less attention. Packaging instructions keeps repeated guidance organized and makes the agent's behavior easier to test.
flowchart TD
A[Project instructions] --> D[Agent context]
B[Prompt file] --> D
C[Task and input] --> D
D --> E[Response or code change]caption: How different instruction sources reach an agent alt: Project instructions, a prompt file, and a task input combine into the agent context, which produces a response or code change.
Persistent Project Instructions as a Baseline
Persistent instructions apply across many tasks in a repository. A file such as AGENTS.md might describe coding conventions, test commands, or files that must not be changed. Keep this layer stable and general.
Do not put a one-time request there. A review request belongs in a reusable prompt file, while repository-wide rules belong in persistent instructions.
> callout note > Treat persistent instructions as policy for the project. Keep them short enough that they leave context for the actual task. > ```
Reusable Prompt Files
A prompt file stores a repeatable task and its expected output. File names and frontmatter fields differ between tools, so check your tool's documentation.
---
description: Review staged changes
---
Review the changes staged in Git.
1. List likely bugs with file and line references.
2. Identify public behavior without tests.
3. Suggest the smallest fix for each finding.
Do not edit files. Reply with a short Markdown list ordered by severity.This file separates the review procedure from the command used to start it. That makes the procedure consistent and easy to revise.
Making Prompt Files Take Inputs
An input lets one prompt file support many tasks. Some tools replace $ARGUMENTS; others use a different placeholder.
---
description: Investigate issue $ARGUMENTS
---
Read issue $ARGUMENTS, find the relevant code, and propose a fix.
Follow CONTRIBUTING.md and add a test that fails without the fix.Validate the input before using it in commands or queries. An input should identify the task, not silently override project rules.
Custom Agents: A Specialist With Its Own Setup
A custom agent packages a role, instructions, and often a restricted tool set. Use one when a workflow needs a stable identity, such as a read-only code reviewer.
---
name: code-reviewer
description: Reviews code for correctness and test coverage
tools: Read, Grep, Glob
---The role should state what the agent checks and what it must never do. Limiting tools reduces accidental edits and narrows the effect of a compromised instruction.
Exercise
Where should a repository-wide testing rule go: a prompt file or persistent project instructions?
Show answer
Persistent project instructions, because the rule should apply across recurring tasks.