agent-testing-harness
Use this skill when testing AI agent systems. Activate when the user needs to test agent behavior, write tests for multi-agent systems, implement agent evaluation frameworks, create test harnesses for autonomous agents, or validate agent outputs systematically.
What this skill does
# Agent Testing Harness
Design and implement comprehensive testing for AI agent systems.
## When to Use
- Building reliable agent systems
- Validating agent behavior before deployment
- Creating regression tests for agents
- Implementing continuous testing for agent updates
- Evaluating agent performance metrics
## Testing Pyramid for Agents
```
┌─────────────────────┐
│ End-to-End │ Full workflow tests
│ Agent Tests │ (expensive, few)
├─────────────────────┤
│ Integration │ Multi-agent interaction
│ Tests │ (medium cost, some)
├─────────────────────┤
│ Component │ Individual agent behavior
│ Tests │ (cheap, many)
├─────────────────────┤
│ Unit Tests │ Tools, utilities, helpers
│ │ (cheapest, most)
└─────────────────────┘
```
## Unit Testing Agent Components
### Testing Tools
```typescript
import { describe, it, expect, vi } from 'vitest';
describe('SearchTool', () => {
const searchTool = new SearchTool();
it('returns results for valid query', async () => {
const result = await searchTool.execute({ query: 'test query' });
expect(result.success).toBe(true);
expect(result.data.results).toBeInstanceOf(Array);
expect(result.data.results.length).toBeGreaterThan(0);
});
it('handles empty query gracefully', async () => {
const result = await searchTool.execute({ query: '' });
expect(result.success).toBe(false);
expect(result.error.code).toBe('INVALID_INPUT');
});
it('respects rate limits', async () => {
// Make many requests quickly
const promises = Array(10).fill(null).map(() =>
searchTool.execute({ query: 'test' })
);
const results = await Promise.all(promises);
const rateLimited = results.filter(r => r.error?.code === 'RATE_LIMITED');
expect(rateLimited.length).toBeGreaterThan(0);
});
});
```
### Testing Prompts
```typescript
describe('SystemPrompt', () => {
it('includes all required sections', () => {
const prompt = generateSystemPrompt(config);
expect(prompt).toContain('## Your Role');
expect(prompt).toContain('## Available Tools');
expect(prompt).toContain('## Constraints');
});
it('correctly formats tool descriptions', () => {
const prompt = generateSystemPrompt({
tools: [
{ name: 'search', description: 'Search the web' },
{ name: 'calculate', description: 'Do math' }
]
});
expect(prompt).toContain('- search: Search the web');
expect(prompt).toContain('- calculate: Do math');
});
});
```
## Component Testing Agents
### Mock LLM Responses
```typescript
class MockLLM {
private responses: Map<string, string> = new Map();
setResponse(inputPattern: RegExp | string, response: string): void {
const key = inputPattern instanceof RegExp ? inputPattern.source : inputPattern;
this.responses.set(key, response);
}
async complete(input: string): Promise<string> {
for (const [pattern, response] of this.responses) {
const regex = new RegExp(pattern, 'i');
if (regex.test(input)) {
return response;
}
}
return 'Default mock response';
}
}
describe('ResearchAgent', () => {
let agent: ResearchAgent;
let mockLLM: MockLLM;
beforeEach(() => {
mockLLM = new MockLLM();
agent = new ResearchAgent({ llm: mockLLM });
});
it('formulates search queries from task', async () => {
mockLLM.setResponse(
/formulate.*search/i,
JSON.stringify({ queries: ['query 1', 'query 2'] })
);
const result = await agent.planResearch('Find information about X');
expect(result.queries).toHaveLength(2);
});
it('synthesizes findings into report', async () => {
mockLLM.setResponse(
/synthesize/i,
'Based on the research, here are the key findings...'
);
const result = await agent.synthesize([
{ source: 'source1', content: 'finding 1' },
{ source: 'source2', content: 'finding 2' }
]);
expect(result).toContain('key findings');
});
});
```
### Testing Agent Decision Making
```typescript
describe('Agent Decision Making', () => {
it('selects appropriate tool for task', async () => {
const agent = new Agent({
tools: [searchTool, calculatorTool, fileReaderTool]
});
// Math task should use calculator
const mathDecision = await agent.decideTool('Calculate 15% of 200');
expect(mathDecision.tool).toBe('calculator');
// Search task should use search
const searchDecision = await agent.decideTool('Find the latest news about AI');
expect(searchDecision.tool).toBe('search');
});
it('handles ambiguous tasks appropriately', async () => {
const agent = new Agent({ tools: [searchTool, fileReaderTool] });
const decision = await agent.decideTool('Read about quantum computing');
// Should clarify or make reasonable choice
expect(['search', 'clarify']).toContain(decision.action);
});
});
```
## Integration Testing Multi-Agent Systems
```typescript
describe('Multi-Agent Workflow', () => {
let supervisor: SupervisorAgent;
let researcher: ResearchAgent;
let writer: WriterAgent;
let reviewer: ReviewerAgent;
beforeEach(() => {
researcher = new ResearchAgent();
writer = new WriterAgent();
reviewer = new ReviewerAgent();
supervisor = new SupervisorAgent({
workers: [researcher, writer, reviewer]
});
});
it('coordinates agents to complete task', async () => {
const result = await supervisor.execute(
'Write a blog post about renewable energy'
);
expect(result.success).toBe(true);
expect(result.steps).toContainEqual(
expect.objectContaining({ agent: 'researcher', status: 'completed' })
);
expect(result.steps).toContainEqual(
expect.objectContaining({ agent: 'writer', status: 'completed' })
);
});
it('handles agent failure gracefully', async () => {
// Make researcher fail
vi.spyOn(researcher, 'execute').mockRejectedValue(new Error('API Error'));
const result = await supervisor.execute('Research topic X');
expect(result.success).toBe(false);
expect(result.error).toContain('researcher failed');
expect(result.recoveryAttempts).toBeGreaterThan(0);
});
it('respects budget constraints', async () => {
const result = await supervisor.execute(
'Complex research task',
{ budgetUSD: 0.01 } // Very low budget
);
expect(result.totalCost).toBeLessThanOrEqual(0.01);
});
});
```
## End-to-End Agent Tests
```typescript
describe('E2E: Content Creation Pipeline', () => {
// Use real LLM but with test account
const agent = new ContentCreationAgent({
llm: new OpenAI({ apiKey: process.env.TEST_API_KEY })
});
it('creates blog post from topic', async () => {
const result = await agent.createContent({
type: 'blog_post',
topic: 'Benefits of unit testing',
targetLength: 500
});
// Structure validation
expect(result.title).toBeDefined();
expect(result.content.length).toBeGreaterThan(400);
expect(result.content.length).toBeLessThan(600);
// Content validation
expect(result.content.toLowerCase()).toContain('test');
expect(result.sections.length).toBeGreaterThanOrEqual(3);
}, 60000); // Long timeout for real API calls
it('handles user feedback loop', async () => {
const draft = await agent.createContent({
type: 'blog_post',
topic: 'AI in healthcare'
});
const revised = await agent.reviseContent(draft, {
feedback: 'Make it more technical and add statistics'
});
expect(revised.content).not.toEqual(draft.content);
// Check for more technical language
expect(revised.content).toMatch(/\d+%|\d+ percent/);
}, 120000);
});
```
## Evaluation Metrics
```typescript
interface AgentEvaluation {
taskCompletion: numbeRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.