AI and agents · Skill + guide

/close: your agent decides what it learns from each session.

I'd correct something, it would write it down, and a few sessions later it would do it again. It wasn't forgetting: it had so many rules in front of it that none of them carried any weight. This skill is the filter I put at the end of every session. It works for Claude Code, for Codex and for any agent that reads instructions: the same folder works for me in both. Here's the file ready to paste, how to adapt it to your project and how to use it without your memory filling up with noise again.

1 markdown file
2 phases: learn and check
4 questions that filter
5 operations, creating is the last
2 minutes to install
What was really going on: an agent's memory is a folder of files plus an index it reads at the start of every session. That index has a cap (in Claude Code, about 200 lines or 25 KB) and mine was full: two hundred lines it read every time, and none of them carried any weight. It's like underlining an entire book: if everything's underlined, nothing is.

The skill, ready to paste

The SKILL.md file, generalized (without my paths or my quirks), and a README with the install for Claude Code, Codex and other agents. Copy the close folder from the zip into your skills folder and type /close (in Codex, $close).

Download the skill (.zip)
Go to the full skill Adapt it to my project What it doesn't do

00

What /close is and what it isn't

2 minutes

A curation pass at the end of the session, on top of the memory your agent already keeps.

⌄

Your agent already keeps memory somehow: Claude Code, for example, writes things down from each session in a folder per project and loads an index at startup. What it doesn't have is your judgment about what deserves to stay, where it'll be read and what can be turned into something a machine checks. That's what this skill does when you type /close. And since it's a text file, the same folder works for me in Claude Code and in Codex.

Phase 1 · Learn

It pulls candidates from the conversation and the diff (your corrections, errors and what they cost, what went well, surprises), runs them through four questions, and whatever survives goes to the place where it'll be read right when it's needed.

Phase 2 · Can I close?

It doesn't remember it, it measures it: branch, uncommitted changes, unpushed commits, running processes, unkept promises, printed secrets. It answers “You can close.” or the list of blockers.

What makes it different from “write everything down”: creating a new file is the last of five operations. First come reinforcing a rule that already exists (one more line), rewriting it, merging two that say the same thing, or deleting what turned out to be false. And “nothing to record” is a valid answer.

It doesn't change a single weight of the model. In agent research this has a name: verbal reinforcement (see the last block). The signal isn't a reward: it's your corrections.

01

Install

2 minutes

One folder, one file, and type /close (in Codex, $close). In Claude Code, in Codex or in both at once.

⌄

A skill is a SKILL.md file inside a folder named after the command. If the folder is called close, in Claude Code you launch it with /close and in Codex with $close (or by picking it in /skills). Both read the same format; the only difference is where they look for the folder and what it's called.

Claude Code, global for all your projects
mkdir -p ~/.claude/skills/close
# copy the SKILL.md from the zip (close/ folder) to:
#   ~/.claude/skills/close/SKILL.md
# (for a single repo only: .claude/skills/close/SKILL.md)
Codex (CLI and app)
mkdir -p ~/.agents/skills/close
#   ~/.agents/skills/close/SKILL.md
Both at once: one folder and two links (that's how I have it)
mkdir -p ~/my-skills/close        # the real folder, where you version it
# paste SKILL.md into ~/my-skills/close/SKILL.md
mkdir -p ~/.claude ~/.agents
ln -s ~/my-skills ~/.claude/skills   # if ~/.claude/skills doesn't exist yet
ln -s ~/my-skills ~/.agents/skills   # if ~/.agents/skills doesn't exist yet
  1. Open your agent in the project. In Claude Code, type /: close should show up in the list. In Codex, type $ or open /skills.
  2. Before you use it for the first time, fill in the “Where everything lives in this project” table at the top of the file (block 03).
  3. At the end of a real session, type /close ($close in Codex) and read the receipt.
If it doesn't show up in the list: check that the file is called exactly SKILL.md, that the folder sits inside skills/ and that the header between --- (name and description) is intact. That's what the agent reads to know when to load it. If you already have a linked skills folder, put close inside that one.
02

The full skill

To copy

The complete file, exactly as it goes in SKILL.md.

⌄
~/.claude/skills/close/SKILL.md
---
name: close
description: Use when the user types /close, or near the end of a session asks whether anything learned (errors, things done well) is still unregistered, or whether they can close the session. Only on their request, never on your own initiative.
---

# Closing the session

Everything you record gets paid for in every future session: either it loads and dilutes what matters, or it
can't be found. A lesson is worth keeping if **it changes what the next session will do** at a recognizable
moment. If not, it's noise. Files can grow with each new principle; what doesn't grow is what always loads
(the index), and neither do duplicates: **a new case of an old principle is one line in its file, not a new
file**.

Arguments: `/close` runs both phases. `/close learn` only phase 1. `/close check` only phase 2.
If phase 1 already ran in this session and nothing has happened since, it isn't repeated.

## Where everything lives in this project (fill this in before using the skill)

| What | Path in my case |
|---|---|
| Agent memory (one file per lesson) | `~/.claude/projects/<project-folder>/memory/` in Claude Code, or your agent's memory folder |
| Index that always loads | `MEMORY.md` inside that folder |
| Repo rules | `AGENTS.md` or `CLAUDE.md` at the root |
| Skills | `~/.claude/skills/` (Claude Code), `~/.agents/skills/` (Codex) or your agent's skills folder |
| The project's closing protocol, if there is one | none |

## Phase 1 · Learn

**1. Candidates.** From the conversation and the diff, not from memory: the user's corrections, errors and
what they cost, what went well and the user confirmed, surprises, time lost on something avoidable.

**2. Filter.** Each candidate passes all four or it's dropped:
- **Trigger:** can I say in what specific situation the next session will use it? If not, it's not a lesson.
- **Not derivable:** do the code, git, a test or the project's docs already say it?
- **Not covered:** search before deciding (`grep -ril` in memory, skills, AGENTS.md, CLAUDE.md,
  the session protocol). Only open what comes up. And also look at the READMEs and the code of whatever
  it touches: what already exists as a script doesn't get proposed again as a lesson.
- **It repeats:** a one-off accident doesn't get written down.

**3. Destination: where it loads right when it's needed, and the cheapest place.**

| What you learned is... | It goes to... |
|---|---|
| Checkable by a machine | a script, test, lint or hook. Always beats a sentence |
| A technique for a type of task | that task's skill |
| A repo rule | its AGENTS.md, CLAUDE.md or session protocol |
| A user preference or correction | memory (one file per principle) |
| State or a to-do | ROADMAP, the project's state file or the to-do list. Never lesson memory |

What always loads (the global instructions, the memory index) is the most expensive space:
only rules that apply to almost every session. Everything else lives behind its door (skill, sub-index, doc).

**4. Operation, in order of preference:**
1. **Reinforce:** add the new case, in one line, to the rule that already exists.
2. **Rewrite:** the existing rule was incomplete or badly worded.
3. **Merge:** two files that state the same principle become one; the other is deleted along with its index line.
4. **Delete:** what this session proved false or out of date.
5. **Create:** only if there's nowhere else. Format: the rule, the case that paid for it in one line, how to apply it. No chronicle.

**5. "Nothing to record" is a valid and frequent answer.** Making up lessons to look useful is the failure
this skill exists to prevent. More than 3 new files in one close is a sign you didn't filter or merge.

**6. Receipt for the user**, short: a `what · where · operation` table. Dropped candidates only if the user
might disagree, with the reason in a few words.

## Phase 2 · Can we close?

It's measured, not remembered. For every repo or worktree touched in the session:
- `git branch --show-current`, `git status --short`, unpushed commits (`git log --oneline @{u}..`).
  Tell this session's work apart from other sessions'; what isn't yours gets named, not touched.
- Processes started in the session (servers, watchers, monitors, agents): are they still running? does it matter if they die?
- Promises: what I said I'd do or the user asked for and isn't done.
- Whatever's left open has a home (ROADMAP, state file, to-dos) with its next action.
- If the project has a closing protocol, run that one, don't duplicate it here.
- Was any secret printed during the session? Flag it so it gets revoked.

**Verdict in one line:** "You can close." or the list of blockers, one per line with the proposed action.
Commits and pushes ask for an OK in a single question.

## Signs you're doing it wrong

| Thought | Reality |
|---|---|
| "There's a lot to learn" | There are probably 0 to 2. The rest doesn't pass the filter |
| "I'll write it down just in case" | Something with no trigger won't be found when it's needed |
| "It's faster to create a new file" | And memory grows until you have to compact it by hand |
| "I'll just leave it in memory" | If code can check it, the sentence will be forgotten and the test won't |
| "Everything's committed" without running git | It's measured |

The description in the header is what the agent reads to decide when to load the skill, so keep it in English even if you translate the rest.

03

Adapt it to your project

5 decisions

The table at the top is the only thing you have to fill in. This is what goes in each row.

⌄
RowWhat to putIf you don't have it
Agent memoryThe folder where your agent keeps lessons. In Claude Code, its automatic project memory (~/.claude/projects/<folder>/memory/). If you keep it somewhere else or share it between agents, that one.In Claude Code, leave the default path: it creates it on its own.
Index that always loadsThe file that's read at the start of every session (in Claude Code, MEMORY.md in that folder). It's the most expensive space: only what applies to almost every session.Same: the default index.
Repo rulesAGENTS.md or CLAUDE.md at the root. That's where rules go that apply to any agent that comes into the repo, not just to you.Create a CLAUDE.md with three lines. Better than sending everything to memory.
SkillsWhere yours live (~/.claude/skills/, ~/.agents/skills/ or your shared folder). A technique for a type of task goes in that task's skill, not in memory.Put your agent's global folder and that's it.
Closing protocolIf your project already has a “before you close” (a checklist in the docs, a script), phase 2 runs it instead of duplicating it.Write “none”. Phase 2 does the basics on its own.

If you only work with the default memory

Fill in the first two rows with the default paths and leave the rest. The skill already does what matters: filter and reinforce instead of creating.

If you have a second brain or several repos

Point memory at your single folder and put your skills where you version them. The rule doesn't change: what always loads is expensive, everything else lives behind its door.

What's best left alone: the four questions, the order of the five operations and the line “nothing to record is a valid answer”. They're the filter. If you loosen them, you're back to writing everything down.
04

The four questions, with examples

The filter

A candidate passes all four or it's dropped. This is what falls at each one.

⌄
QuestionPassesDoesn't pass
Trigger. In what specific situation will the next session use it?“Before calling a test that uses grep -c green, read the whole output.” It has a moment.“We need to be more careful with tests.” There's no moment when that fires.
Not derivable. Do the code, git, a test or the docs already say it?A preference of yours that no file in the repo can hold.“The project uses Next 16.” package.json says so. Writing it down is duplicating.
Not covered. Is it already written down in memory, skills or repo rules?You searched with grep and nothing came up.A rule came up that already says it. Then it's a new case: one more line in that file, not a new file.
It repeats. Will it happen again?A method failure that fires every time you do X.A one-off accident (the API being down that Tuesday).
The trick in question 3: search before deciding. Most of what an agent wants to write down when closing already exists somewhere. That search is what turns “create” into “reinforce”, and it's the difference between a memory that grows and one that gets better.
05

Where each lesson goes

The destination table

Where it loads right when it's needed, and the cheapest place.

⌄
What you learned is...It goes to...Why
Checkable by a machineA script, a test, a lint or a hookA sentence depends on the agent remembering to read it. A lint goes red whether it remembers or not. It always wins.
A technique for a type of taskThat task's skillIt only loads when that task comes up, not in every session.
A repo ruleAGENTS.md, CLAUDE.md or the session protocolIt applies to any agent that comes in, not just yours.
Your preference or correctionMemory, one file per principleIt's the only thing that really doesn't live anywhere else.
State or a to-doROADMAP, state file, to-do listNever lesson memory: state goes stale and a lesson doesn't.
A real example, from my app: in July I fixed a crash when deleting an item. Four days later it was back, because the lesson lived in a sentence. Today it's an ESLint rule (eslint --max-warnings=0 with the hooks rule) that I run before every build: if the bug comes back, it goes red. The skill doesn't write the lint on its own: it sends every lesson of that kind to that destination, and the agent writes it in that same session.

An example receipt, in the shape the skill returns (the content is an example, not a literal close):

WhatWhereOperation
A test that passes by accident (grep -c || echo 0 doubled the zero): read the whole output, new casememory, an existing file about tests that pass by accidentreinforce
The hooks lint, before every buildpackage.json, lint:hooks scriptmachine
“Don't ask for permission for steps the approved plan already covers”memory, new filecreate

And underneath, the phase 2 verdict: “You can close.” or, for example, “2 unpushed commits on feat/x; the dev server is still running (doesn't matter)”.

06

How to use it well

The habit

What I've learned using it every week, and what happens if you don't.

⌄
  1. At the end, not halfway through. The skill looks at the whole conversation and the diff. Halfway through a session the diff isn't finished and the corrections haven't stung yet.
  2. Read the receipt. It's short on purpose. If a row looks wrong to you, say so right then: fixing a lesson that was just written costs one sentence; fixing it three weeks later costs finding it.
  3. “Nothing to record” is good news. It means the filter did its job. Don't ask it to find something.
  4. More than three new files in one close is an alarm. It almost certainly didn't search before creating. Ask it to repeat question 3 on those three.
  5. Use the arguments. /close check (in Codex, $close check) when you only want to know whether you can leave. /close learn when you've already closed git but there was a big correction.
  6. Keep an eye on the index. What always loads has a cap (in Claude Code, about 200 lines or 25 KB for the memory index; in other agents, whatever their docs say). If you go over it, whatever's at the bottom stops loading without warning. When it gets close, compact it: long rules move down to their own file and the index keeps one line.
What I measured in my own use, in case it's useful as a reference: in one week with the skill, of everything it recorded, the new files were two or three. Almost everything was adding a line to a rule that already existed. That's what you want to see.
07

What it doesn't do

Honest limits

So you don't ask it for what it can't give.

⌄
  • It doesn't measure on its own how many errors it prevents. I haven't measured that either. What you can see is that it stops creating files and starts reinforcing.
  • The one deciding what counts as a lesson is the same model. Two of the four questions are mechanical (searching with grep, checking whether the code already says it); the other two are judgment. That's why you read the receipt: your correction is the signal.
  • It doesn't govern the memory a session writes mid-work. The agent keeps saving things on its own while it works (Claude Code certainly does). If you want that to go through the filter too, add to phase 1 that it reviews the memory files created during the session (git status on that folder, if you version it).
  • It doesn't replace your agent's memory. It sits on top. If your agent has none, the skill has nowhere to reinforce: give it at least a folder and an index.
  • It isn't reinforcement learning in the strict sense. It doesn't touch weights. It's text memory updated with your feedback, which is what the literature calls verbal reinforcement.
08

In other agents

It's text

The skill is a markdown file. Any agent that reads instructions can follow it.

⌄

What makes it work isn't the skill format, it's the two phases, the four questions and the destination table. Claude Code and Codex load it as is (block 01). In another agent, paste the body of the file (everything below the --- header) as a “When closing a session” section of your AGENTS.md, or as a saved prompt you run when you finish. Swap the paths in the table at the top for that agent's: where it keeps its memory and which file it always loads.

What I haven't tested: phase 2 assumes the agent can run git and see processes. In an agent without a terminal, stick with phase 1.
09

Where it comes from

Three papers

In case you want to read what's behind “verbal reinforcement”.

⌄
  • Reflexion (Shinn et al., 2023). Agents that improve by keeping text reflections on what went wrong, without touching weights. The paper calls it “verbal reinforcement learning”. The difference with this skill: Reflexion repeats the same task with a signal from the task itself (tests, reward); here different tasks cross over and the signal is your corrections. arXiv 2303.11366
  • ExpeL (Zhao et al., 2024). Lessons across tasks with four operations: add, edit, upvote and downvote. It's the closest analog to reinforce, rewrite, create and delete. arXiv 2308.10144
  • ACE (2025). It warns about the “context collapse” caused by rewriting the context over and over, and proposes small changes and deduplication. It's the reason for “reinforce with one line” and for not creating by default. arXiv 2510.04618