Agent skill

smith-prompts

Prompt engineering standards for AI interactions with cache optimization. Use when writing AI prompts, optimizing context usage, or structuring AGENTS.md files. Covers prompt caching, token efficiency, and progressive disclosure patterns.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/tianjianjiang/smith/tree/main/smith-prompts

SKILL.md

Prompt Engineering Standards

  • Load if: Writing AI prompts, optimizing context usage
  • Prerequisites: @smith-principles/SKILL.md

CRITICAL: Prompt Caching (Primacy Zone)

Cache reduces costs 90%, latency 85%

Structure for caching:

  1. Static content first (methodology, rules)
  2. Tool definitions in consistent order
  3. Project context (AGENTS.md, docs)
  4. Dynamic content last (recent changes)

Cache breakpoints: Every ~1024 tokens. Prefix must be identical for cache hit.

  • Reordering tools between calls
  • Injecting dynamic content into static sections
  • Modifying cached prefix unnecessarily
  • Using Markdown tables (see @smith-skills/SKILL.md - use bullet lists instead)

AGENTS.md Cache-Friendly Structure

markdown
<!-- STATIC - cached -->
<metadata>

Scope, Load if, Prerequisites

</metadata>

<required>

Critical NEVER/ALWAYS rules

</required>

<forbidden>

Anti-patterns

</forbidden>

<!-- CACHE BREAKPOINT (~1024 tokens) -->

<!-- DYNAMIC - not cached -->
<examples>

Code examples that evolve

</examples>

Token Efficiency

Progressive Disclosure

Three-level loading:

  1. Metadata only (50 tokens)
  2. Core concepts when triggered (200 tokens)
  3. Full details when accessed (1000+ tokens)

Sparse Attention

Efficient file reading:

  1. Grep to find location
  2. Read with offset/limit for large files
  3. Read only necessary context (±20 lines)
  • Loading full files when targeted reads suffice
  • Reading documentation when metadata answers the question
  • Repeating user's question in responses

Structured Output

Platform mechanisms:

  • OpenAI: JSON Schema with strict: true (100% compliance)
  • Anthropic: Tool use with flexible schemas
  • Gemini: responseSchema with retry

Schema design:

  • Match existing project patterns
  • Include descriptions for complex fields
  • Define required vs optional fields
  • Keep nesting ≤3 levels
  • @smith-ctx/SKILL.md - Progressive disclosure, reference-based communication
  • @smith-xml/SKILL.md - Approved XML tags

ACTION (Recency Zone)

For caching:

  • Place static content before dynamic
  • Maintain consistent tool order
  • Target >80% cache hit rate

For efficiency:

  • Use Grep before Read
  • Read incrementally (narrow → expand)
  • Use file:line references

Expand your agent's capabilities with these related and highly-rated skills.

tianjianjiang/smith

smith-style

File naming, path standards, and conventional commits. Use when naming files, creating branches, writing commit messages, or setting up new projects. Covers underscore vs hyphen conventions, commit format, and branch naming patterns.

1 0
Explore
tianjianjiang/smith

smith-stacks

Stacked pull request workflows for large features. Use when creating stacked PRs, managing dependent PRs, or rebasing after parent merges. Covers stack creation, merge order, and squash merge handling.

1 0
Explore
tianjianjiang/smith

smith-python

Python development with uv, pytest, ruff, and type hints. Use when writing Python code, running tests, managing Python packages, or working with virtual environments. Covers import organization, type hints, pytest patterns, and environment variables.

1 0
Explore
tianjianjiang/smith

smith-principles

Fundamental coding principles (DRY, KISS, YAGNI, SOLID, HHH). Use when starting any development task, evaluating implementation approaches, or reviewing code quality. Always active as foundation for all development decisions.

1 0
Explore
tianjianjiang/smith

smith-nuxt

Nuxt 3 development patterns including auto-import stubbing for tests, environment variable conventions, and middleware testing. Use when working with Nuxt projects, testing Nuxt components/middleware, or configuring Nuxt environment variables.

1 0
Explore
tianjianjiang/smith

smith-plan

Plan tracking protocol (portable). Progress tracking with checkboxes, iteration workflow, completion/blocker signals. Use when executing multi-step plans, tracking task progress, or working from plan files. IMPORTANT - Always update the plan file after completing tasks.

1 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results