Skip to content
Nerdy beta

Few-Shot Example Integration

One good example teaches the model more than a paragraph of instructions, and a library of them, selected per task, beats pasting the same sample into every chat. Few-shot example integration wires a directory of exemplars into your AI surface so the closest matches show up automatically and the quality bar compounds.

Overview

Few-shot prompting means showing the model what good looks like instead of only describing it. The integration problem is the next step up: you don’t have one example, you have a directory of past work, and you want the surface to pull the two or three that actually match the request rather than making you hand-pick and paste every time. This is context engineering applied to examples, and it’s the library-scale version of the Examples field the heavier prompt frameworks (CREATE, STOKE) already make you fill.

It also fixes a specific failure mode. Pasting the same gold sample into every new chat is the one-time win that vanishes when you close the tab, the pattern behind AI without ROI. Wiring the examples into the surface makes the selection durable: the setup gets better as the library grows, which is compounding engineering in practice.

The governing difference across surfaces is who controls selection. Projects picks examples for you through RAG, which is opaque. Cowork and Claude Code are agentic, so you author the selection logic and can see exactly what got read. One rule holds everywhere: examples are the quality bar to emulate, never content to copy verbatim, and never a factual source for the task.

Claude Projects

Put the example files in the project knowledge base, ideally consolidated into one file (for example EXAMPLES.md) so the full set stays coherent instead of getting chunked by RAG. Paste this into Project instructions.

## Few-shot examples
The project knowledge base contains example [OUTPUT_TYPE]s that define the
target quality bar, structure, and voice. Treat them as exemplars to emulate,
never as content to copy verbatim, and never as factual source for the task.

Before drafting:
1. Identify the 2-3 examples that most closely match the current request on:
   domain/industry, deliverable structure, and scope/complexity.
2. Infer the shared patterns across them: section order, headings, depth of
   detail, and tone.
3. Produce output that follows those patterns, using only the facts in the
   current request.

If the examples are delivered as a single consolidated file (e.g.,
EXAMPLES.md), read it in full and weight the closest matches most heavily.
Do not mention the examples or this selection process in your output.

Once knowledge approaches the context limit, paid plans silently switch to RAG and surface only a subset you can’t control. If you need every example present each time, keep the consolidated file under that threshold.

Claude Cowork

Create the project with “Use an existing folder” (or add the folder as Context) pointing at a directory that contains an examples/ subfolder. Cowork is agentic, so it reads files on demand, which is real dynamic selection. Paste this into Project instructions.

## Few-shot examples (dynamic selection)
Example [OUTPUT_TYPE]s live in `./examples/`. They are the quality bar and
structural template: emulate, never copy.

For every drafting task:
1. List `./examples/` and read the file names / front-matter.
2. Select the 2-3 examples that best match the current input on:
   domain/industry, deliverable structure, scope/complexity.
   Prefer any file prefixed `gold-` if present.
3. Read those files in full before writing.
4. Mirror their structure, sectioning, and tone; use only the current task's
   facts for content.
5. After completing the task, record in project memory which examples you used
   and any pattern that worked, so future tasks can reuse that judgment.

If the folder is large, select first, then read only what you need: never
load the entire directory.

Project-scoped memory means selection judgment compounds across runs, which the chat surface can’t do.

Claude Code

Use two layers: eager @-imports for a tiny canonical set that’s always in context, and lazy on-demand reads for the full library. Add this to CLAUDE.md.

## Few-shot examples

### Canonical (always loaded)
These define the non-negotiable quality bar for every [OUTPUT_TYPE]:
@examples/gold-01.md
@examples/gold-02.md

### Example library (load on demand)
The full example set lives in `examples/`. Do NOT load the whole directory.
When drafting a [OUTPUT_TYPE]:
1. Use Glob/Grep to scan `examples/` and shortlist by filename / front-matter.
2. Select the 2-3 closest matches on: domain/industry, deliverable structure,
   scope/complexity.
3. Read only those files, then draft.
Treat all examples as structural and voice exemplars: emulate, never copy.

@-imports load in full at launch and cost tokens every session (recursion is capped at 4 hops), so keep the canonical set to one or two files and leave the rest lazy. To make the select-and-read step repeatable, wrap it in a slash command at .claude/commands/draft.md.

---
description: Draft a [OUTPUT_TYPE] using dynamically selected few-shot examples
---
Target request: $ARGUMENTS

1. Glob `examples/` and list candidates.
2. Select the 2-3 examples best matching the request on domain, structure, and
   scope. Prefer `gold-*` files.
3. Read the selected examples in full.
4. Draft the [OUTPUT_TYPE], mirroring their structure and voice, using only the
   facts in the target request.
5. Do not reference the examples or the selection process in the output.

Choosing a Surface

SurfaceSelectionYour controlMemoryBest for
ProjectsRAG, opaqueNoneNoneA small, stable example set; fastest setup
CoworkAgentic, on-demandYou author the ruleProject memory compounds judgmentFolder-native work without CLI ceremony
Claude CodeGlob-select + pinned canonicalFullVia committed files and commandsMaximum control over the quality floor

A concrete shape: for a statement-of-work pipeline, pin one or two anonymized gold SOWs as the always-on quality bar, then treat the rest of the anonymized library as a lazy, glob-selected pool. The selection rubric (client type, engagement shape, deliverable mix) does the per-input matching, and no single example ever gets copied wholesale.

Resources

  • Context Engineering — examples are one of the highest-leverage forms of context you can supply
  • Prompt Frameworks — the CREATE and STOKE frameworks bake an Examples field into a single prompt; this is the library-scale version
  • Compounding Engineering — wiring examples into a surface is how a one-time sample becomes a system that improves with use
  • Effective AI — context engineering lands in Session 2; example-driven setups get built into something durable in Session 3