Skip to content

What is an Agent

Agents are specialized AI assistants that run in separate context windows, enabling focused work without polluting your main conversation. Learn when to use agents versus tools, and how context isolation drives their core benefits.

An agent is a configured AI context. It combines a role definition, relevant context files, tool access, and behavioral instructions.

AspectDescriptionExample
RoleWhat the agent is"You are an onboarding assistant for this Java monorepo"
ContextWhat it knowsAGENTS.md, copilot-instructions.md, README
ToolsWhat it can doFile read/write, bash, web search, MCP servers
BehaviorHow it actsAlways run tests before suggesting a PR

When to create an agent: when the same role + context + behavior will be used repeatedly across your team.

Anatomy

Agents are packaged as markdown files with YAML frontmatter, defining their capabilities, constraints, and behavior.

Structure of an agent

Agents are defined as markdown files with YAML frontmatter:

text
.claude/agents/                   # For Github Copilot ~/.github/agents/
    code-reviewer/
    ├── code-reviewer.md          # Agent definition (required)
    └── scripts/                  # Validation scripts (optional)
        └── validate.sh

Example agent file (Claude Code)

markdown
---
name: api-developer
description: Build API endpoints following team conventions. Use when implementing REST APIs or microservices.
tools: Read, Edit, Write, Bash, Grep, Glob
model: sonnet
memory: project
permissionMode: acceptEdits
skills:
  - api-conventions
  - error-handling-patterns
mcpServers:
  - github
  - playwright:
      type: stdio
      command: npx
      args: ["-y", "@playwright/mcp@latest"]
---

You are an API development specialist. When invoked:
1. Review preloaded skills for team conventions
2. Implement endpoints following established patterns
3. Use GitHub tools to reference related PRs
4. Use Playwright tools to test endpoints in browser
5. Include proper error handling and validation

Always follow the conventions from your preloaded skills.

Example agent file (GitHub Copilot)

markdown
---
description: "Use when: creating user stories, writing feature requests, defining acceptance criteria, describing new stories, PM story grooming, backlog refinement, story templates, feature specifications, requirement definitions"
name: "Story Writer"
tools: [read, search, edit]
argument-hint: "Briefly describe the feature, change, or requirement you want to document as a story"
---

You are a **senior product manager** specializing in translating business requirements into well-structured, unambiguous user stories that engineers can implement without guesswork.

Note: Agents from the GitHub Copilot extension in VS Code use a different frontmatter schema than Claude Code agents.

Key frontmatter fields

FieldPurposeExample
nameUnique identifiercode-reviewer
descriptionWhen Claude should delegate to this agent"Use proactively after..."
toolsWhich tools agent can accessRead, Grep, Glob, Bash
modelModel to use (sonnet, opus, haiku)sonnet
memoryPersistent memory scope (user, project)project
permissionModePermission handling (default, auto, plan)auto
skillsPreload skills into agent's contextapi-conventions
mcpServersMCP servers available to this agentgithub, slack

When to Use Agents

ScenarioUse AgentWhy
Running tests with verbose outputYes - isolate in subagentKeeps test logs out of main context
Parallel research on multiple modulesYes - spawn multiple agentsEach explores independently, returns summary
Enforcing read-only database queriesYes - restrict tools with hooksValidate commands before execution
Quick code change in current contextNo - work in main conversationNo need for context isolation
Iterative refinement with userNo - stay in main threadFrequent back-and-forth benefits from shared state

Agent Types & Examples

Built-in agents (Claude Code)

NamePurposeToolsContext Strategy
ExploreFast codebase searchRead-onlyIsolates exploration from main
PlanResearch for planning modeRead-onlyPrevents infinite nesting
general-purposeComplex multi-step tasksAll toolsHandles exploration + modification

Custom agent examples

NamePurposeToolsContext Strategy
code-reviewerReview code qualityRead, Grep, Glob, BashRead-only review without edits
testerRun tests and report failuresBash, Read, GrepIsolates verbose test output

References

Copyright © MSG Systems Romania AI Labs