# Skills Inside the Loop

Course: [Loop Engineering](https://www.devtutorials.ai/learn/loop-engineering) · Section: First Loop
Source: https://www.devtutorials.ai/learn/loop-engineering/first-loop/skills-and-v1-export

> Plus your v1 export. Move 300 pasted lines of instructions into a triage skill, watch the tokens per turn drop by more than half, then export your first loop pack for Claude Code, Codex or Cursor.

## What a Skill Does in a Loop

A loop runs many turns. Anything you paste into its prompt is read again on every one of them. In this lesson, you move long instructions into a **skill**, so the loop reads less. Then you export your loop as files for your own tool.

The agent forgets everything between turns.

So a loop with a long manual pastes the whole manual again, every turn.

For example, a triage manual of 300 lines is read:

- on the turn that fixes a typo
- on the turn that retries a broken fix
- on the one turn that really needs it

**Simple lesson:** in a loop, you pay for pasted text on every turn.

### A Real-World Example

Think about a cook in a busy kitchen.

Before every dish, someone reads the whole cookbook out loud. The cook hears all 300 pages, again and again. Most of it has nothing to do with this dish.

A better kitchen keeps the cookbook on a shelf. The spine says what is inside. When the cook needs the bread recipe, they open that page.

In a loop:

- **Reading the book aloud** = pasting instructions into every prompt.
- **The book on the shelf** = the skill.
- **The words on the spine** = the skill's description.
- **Opening the right page** = the agent loading the skill when a ticket needs it.

Click the button and run the loop in the Loop Lab.

- **The tokens column:** every turn reads about 5,700 tokens.
- **Most of that:** the same 300 lines, read again.
- **The results:** fine. The loop works. It is just expensive.

**Simple lesson:** a loop that works can still waste most of what it reads.

## What You Will Learn

In this lesson, you will learn:

1. Why pasted instructions get expensive in a loop.
2. What a skill is, and how the agent finds it.
3. How to check that a cheaper loop still gives the same results.
4. What is inside a loop pack.
5. How to export your loop for your tool.

## Why Pasting Gets Expensive

### The Manual, Turn After Turn

Watch the same loop run, one turn at a time. The yellow part of the bar is the pasted manual:

Press **Play**, or use **Next** to go one step at a time.

- **Frame 1:** the first turn. Most of its tokens are the manual.
- **Frame 2:** ticket #12 is unclear. This is the one turn that needed the triage rules.
- **Frame 3:** the yellow part keeps growing. It is already past the line.
- **Frame 4:** the same run with a skill. The whole run fits under the line.

### Why It Adds Up

One prompt is cheap. A loop is many prompts.

A daily loop with 5 turns reads the manual 5 times a day, 35 times a week. Each time, it pays for all 300 lines.

**Simple lesson:** count tokens per turn, then multiply by every turn the loop will ever run.

## What a Skill Is

**Skill** = a folder with a `SKILL.md` file that holds the know-how for one job.

The **Agent Skills** course on this site teaches skills in depth. Here you only need the shape.

At the top of the file is a short header with a **name** and a **description**. Below it are the steps.

```md
---
name: triage
description: Use when a loop picks up a ticket. Decide whether to fix it, skip it, or send it to the triage inbox, before writing any code.
---

# Triage a ticket

1. Read state.md. If the ticket is ticked, skip it.
2. Does the ticket say what "done" means, as a check? If not, send it to the triage inbox.
3. Does it touch production data, secrets or deletes? Send it to the triage inbox.
4. Otherwise, fix it. Run the tests before you say done.
5. Write one line to state.md, only after the checker passes.
```

### How the Agent Finds a Skill

Real tools usually work in two steps:

1. At the start, the agent reads only each skill's **description**.
2. When a job matches a description, it opens the full `SKILL.md`.

So the description must say **when** to use the skill. "Helps with tickets" does not. "Use when a loop picks up a ticket" does.

**In this lab**

- Real tools load a skill's steps only when a job needs them.
- In this lab, a skill costs a small, fixed number of tokens on every maker turn.
- That keeps the numbers simple. The skill still costs far less than the pasted manual.

### Where Skills Live in Each Tool

Each tool reads `SKILL.md` from its own folder:

- **Claude Code:** `.claude/skills/<name>/`
- **Codex:** `.agents/skills/<name>/`. You can also call a skill with `$name`.
- **Cursor:** `.cursor/skills/<name>/`

**Simple lesson:** a skill keeps the know-how on the shelf, and its description says when to take it down.

## Same Results, Fewer Tokens

### Cheaper Is Not Enough

Cutting tokens is only good if the loop still does the job. So you compare the **scorecard** before and after.

**Scorecard** = the lab's count of what a run did: fixed, escalated, false "done".

There is a trap. You could delete the manual and add nothing:

Step through all three frames.

- **Frame 1:** with nothing, the loop is cheapest.
- **Frame 2:** but unclear ticket #12 is guessed and marked done. The know-how was deleted, not moved.
- **Frame 3:** with a skill, the loop is cheaper **and** #12 still goes to the inbox.

### Lab Exercise: Move the Instructions into a Skill

Click the button to open the loop file in the lab.

1. Under `maker:`, delete the `prompt_file:` line.
2. Add `skill: triage` in its place, with the same two spaces in front.
3. Press **Check my loop**.

Your loop passes when, on all 3 versions:

- each maker turn reads at least half as many tokens as before
- the scorecard stays the same, so #12 still lands in the inbox

**Stuck?** Read the **Loop linter** under the editor.

- The linter is a checker for the loop file itself.
- It names missing parts while you type.
- It never grades you. The check does that.

**Simple lesson:** keep a change that saves tokens only if the scorecard stays the same.

## Your v1 Loop Pack

### Everything You Built

You now have every part of a working goal loop:

- a trigger with a goal a program can check
- a state file
- a maker and a separate checker
- stop rules and an escalation target
- a triage skill

**Loop pack** = your loop, turned into the real files your tool expects.

The **Export** tab in the Loop Lab builds it for you.

### What Is in the Pack

- **`loop.yaml`:** your loop, in the shape you wrote in the lab.
- **`state.md`:** an empty state file for the first run.
- **Maker and checker files:** the two agents, in your tool's folder and format.
- **`SKILL.md`:** the triage skill.
- **`LOOP-COMMAND.md`:** how to start the loop in your tool.
- **`LOOP-README.md`:** your stop rules and a checklist for the first real run.
- **`.github/workflows/loop.yml`:** only for loops that run on a schedule.

### One Loop, Three Tools

Here is the same loop, exported for each tool:

Step through all four frames.

- **Frames 1 to 3:** the files are the same jobs. Only the folders change, and Codex writes its agents as `.toml` files.
- **Frame 4:** a pack whose skill lost its description. The check fails, so you cannot download it.

**Important:** tool file layouts change often.

- The pack follows the layout checked on 19 Oct 2026.
- Before your first real run, check each path in your tool's docs.
- `LOOP-README.md` in the pack reminds you.

### Export Your Pack

1. In the Loop Lab, open the **m5-skill** scenario with your passing loop.
2. Open the **Export** tab.
3. Pick your tool. Click each file to read it.
4. Press **Download**.

The first real run is up to you, and it is not graded. Start the loop on 2 or 3 small tickets, and read every diff on the first day.

**Simple lesson:** export the loop, check the paths, and start small.

## TL;DR

1. **Pasted instructions** = text read again on every turn of the loop.
2. **Skill** = a folder with a `SKILL.md` that holds the know-how for one job.
3. **Description** = the line that tells the agent when to open the skill.
4. **Scorecard** = what a run did: fixed, escalated, false "done".
5. **Safe saving** = fewer tokens per turn, and the same scorecard.
6. **Loop linter** = feedback on the loop file while you type. It never grades.
7. **Loop pack** = your loop as real files for your tool:
   - `loop.yaml` and `state.md`
   - maker and checker agents
   - the triage skill
   - how to start it, and a first-run checklist

## Common mistakes

| Mistake | Wrong idea | Correct idea | What goes wrong |
|---|---|---|---|
| Pasting a manual into the prompt | "More instructions, better results." | Put the manual in a skill. | Every turn pays for the whole manual. |
| Deleting instead of moving | "Fewer tokens is always better." | Keep the know-how. Move it into a skill. | The maker guesses on unclear tickets. |
| A vague description | "Helps with tickets" is enough. | Say when: "Use when a loop picks up a ticket." | The skill is never opened. |
| Not checking the scorecard | "It is cheaper, so it is better." | Compare fixed, escalated and false "done". | A broken loop looks like a saving. |
| Trusting the export blindly | "The paths must be right." | Check each path in your tool's docs. | The tool ignores a file in the wrong folder. |

## Check Your Understanding

## Exercises

Press **Check** when you are ready. Use **Show Hint** if you get stuck.

## What to Remember

- In a loop, anything in the prompt is read again on every turn.
- A skill keeps the know-how in a file. Its description says when to open it.
- Moving the manual into a skill cut each maker turn by more than half.
- Deleting the manual is cheaper, but the loop starts guessing.
- Keep a saving only if the scorecard stays the same.
- The Export tab turns your loop into a loop pack. Check the paths in your tool's docs.

## Further Reading

- [Loop engineering: designing loops you can walk away from, by CodeRabbit](https://coderabbit.ai/blog/loop-engineering): skills that are read on every pass.
- [Loop Engineering, by Addy Osmani](https://addyosmani.com/blog/loop-engineering): skills as one of the building blocks.
- The **Agent Skills** course on this site covers writing skills in depth.

Next: **Worktrees and Parallel Loops**. Two agents share one folder and lose a fix, so you give each agent its own copy.
