#AI

An Engineer’s Guide to Better AI Skills: Implementing a Testing Process to Optimize Agent…

An Engineer’s Guide to Better AI Skills: Implementing a Testing Process to Optimize Agent…
01

Summary

Stop Guessing, Start Testing: Pinterest's Guide to Optimizing AI Agent Skills

Boost your AI agent's reliability from 60% to near-perfection with a data-driven testing framework.

Learn how Pinterest Engineering quantifies and improves the reliability of custom AI skills. This guide explores building a test harness, benchmarking Codex and Claude, and implementing proven optimization techniques for complex repositories.

  • 01Automating AI performance measurement using a Bash-based test harness
  • 02Defining Positive and Negative test cases to detect false positives in skill usage
  • 03Strategic use of Frontmatter and AGENTS.md for context-aware skill loading
  • 04Comparative analysis of optimization impact on OpenAI Codex vs. Anthropic Claude
  • 05Practical evidence that explicit intent and verbose instructions are the ultimate reliability drivers

RECOMMENDATION

Engineering teams using AI agents should prioritize building a quantitative test harness over qualitative feedback to ensure workflow reliability.

The Problem

AI agents showed unreliability in invoking specific domain-specific skills, such as Pinterest's iOS architecture rules, hindering the automation of engineering workflows.

The Solution

The team implemented a Bash-based test harness to track skill invocation rates across positive and negative cases and applied optimizations like frontmatter descriptions and AGENTS.md skill tables.

The Result

Baseline accuracy (73% for Codex, 62% for Claude) was significantly improved through contextual frontmatter descriptions, achieving consistent results when intent was clear.

Trade-off

Optimizing AGENTS.md increases token usage in the context window, and AI-driven self-improvement of prompts unexpectedly led to lower invocation rates in some cases.

03

Key Concepts

Concept · 01

Skill Invocation

The process where an AI agent recognizes and activates a specific set of pre-defined rules or domain knowledge to complete a task.

  • Measured how reliably agents loaded the 'rx-mvvm-architecture' skill based on various prompts.
Concept · 02

Test Harness

An automated testing framework composed of scripts and tools designed to run tests and collect performance metrics.

  • A Bash script was used to pipe prompts to agents and parse JSON-streamed debug logs for success patterns.
Concept · 03

Frontmatter

A metadata section at the beginning of a file used to provide instructions or context to an AI agent.

  • Used to include detailed architectural components which served as a signal for the agent to load the correct skill.