Skip to content

Commit d51a80a

Browse files
feat(.ai): memory and session retro skill to self-document
- adds session-retrospective skill to capture lessons after work or user corrections - adds memory directory with initial testing lessons
1 parent 6a6063b commit d51a80a

File tree

4 files changed

+189
-0
lines changed

4 files changed

+189
-0
lines changed

.ai/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ Skills are used on-demand. When a task matches a skill’s purpose, the agent re
243243
- Use when: Explaining how code works, teaching about the codebase, or when the user asks “how does this work?”
244244
- Approach: Analogy → diagram → step-by-step walkthrough → highlight gotchas
245245

246+
#### Session retrospective
247+
248+
- **purpose**: Document lessons learned after completing work, especially when the user corrected planning documents or implementation; maintains persistent lesson files in `.ai/memory/` that future agents read at session start
249+
- **How to invoke**: Say "document what you learned", "add to lessons", "remember this", or "run a retrospective". Also triggered when the user corrects your work or you encounter a surprising constraint.
250+
- Use when: User corrects your work, you hit a non-obvious tool limitation, or at session end after substantial work
251+
- Provides: Workflow for capturing lessons, format guidelines, naming convention (`<descriptor>-lessons.md` in `.ai/memory/`)
252+
246253
#### Session handoff
247254

248255
- **purpose**: Create handoff documents so another agent (or a later session) can continue work with full context

.ai/memory/agnostic-lessons.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Lessons learned
2+
3+
Accumulated lessons from working sessions on this project. Grouped by category. Update in place — do not append chronologically.
4+
5+
---
6+
7+
## File operations
8+
9+
- **Edit tool requires a prior read**: The Edit tool fails with "file not read yet" if the file wasn't read in the current conversation, even if you wrote it in the same session. Read every file you plan to edit before starting work.
10+
- **Parallel edits can fail with "modified since read"**: When editing multiple files in the same batch, if one edit changes the file order or content, subsequent edits in the same pass may fail. Re-read the file and retry individually.
11+
12+
---
13+
14+
## Path resolution
15+
16+
- **`2nd-gen/packages/swc/AGENTS.md` is 3 levels deep**: Relative paths from this file need `../../../` to reach the repo root — not `../../`. Wrong: `../../linters/foo.js`. Correct: `../../../linters/foo.js`.
17+
- **Symlink removal with `rm`**: `rm` on a symlink removes only the pointer, not the target directory or files. Safe to use when cleaning up a symlink.
18+
- **Git stores symlinks as text blobs**: Staged symlinks appear as the raw target path string in the index, not the resolved content. This is why Cursor shows "Apply Manually" on staged symlink files — it reads the index, not the filesystem.
19+
20+
---
21+
22+
## Project structure
23+
24+
- **Root `package.json` has `"type": "module"`**: All `.js` scripts in this repo use ESM `import`/`export` syntax. Write new scripts with `import`, not `require`.
25+
- **`linters/` is at the repo root**: The `stylelint-property-order.js` and ESLint plugin live at `linters/`, not inside `2nd-gen/` or `1st-gen/`.
26+
- **`.ai/memory/` is the persistent lessons store**: Lessons and cross-session notes belong here, not in session-handoff documents or code comments.
27+
28+
---
29+
30+
## Component patterns
31+
32+
- **`.internal.stories.ts` files don't need `migrated` tag**: Files named `*.internal.stories.ts` (e.g. `icon.internal.stories.ts`) are dev-only and are exempt from the `tags: ['migrated']` requirement on the meta object.
33+
- **`utility` is a valid meta tag**: The `typography` component uses `tags: ['migrated', 'utility']` on its meta — `utility` is a legitimate tag alongside `migrated`.
34+
35+
---
36+
37+
## Agent tooling
38+
39+
- **Claude Code does not auto-discover `SKILL.md` files**: Skills must be explicitly loaded via `AGENTS.md` context or manual invocation. There is no automatic glob-based discovery.
40+
- **Per-file symlinks allow different extensions**: `.cursor/rules/*.mdc` can symlink to `.ai/rules/*.md` — this lets Cursor find its expected `.mdc` format while the canonical source stays as `.md`.
41+
- **Cursor reads the git index for staged symlinks**: At commit time Cursor sees the symlink path string, not the resolved content, so rules appear as "Apply Manually". At runtime on the filesystem, symlinks resolve correctly.
42+
43+
---
44+
45+
## CI / build
46+
47+
- **`yarn lint:ai` runs the AI tooling validator**: `node .ai/scripts/validate.js` checks story tags, AGENTS.md paths, and config schema. Run it locally before pushing with `yarn lint:ai`.
48+
- **Validator found a real broken link on first run**: The `2nd-gen/packages/swc/AGENTS.md` path to `stylelint-property-order.js` was genuinely wrong — the CI check is worth running even on mature files.

.ai/memory/css-styling-lessons.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CSS Styling Lessons
2+
3+
## Component patterns
4+
5+
**CSS selector syntax — class vs. attribute:** `:not([.swc-Badge--no-label])` uses attribute selector syntax on a class name and always evaluates false; the correct form is `:not(.swc-Badge--no-label)`. When writing negation or `:has()` selectors, use `.class` for BEM modifiers, never `[.class]`.
6+
7+
**Check that every custom property is actually consumed:** Setting `--swc-badge-padding-inline-start` in a `:has()` rule is a silent no-op if the base rule uses `padding-inline` shorthand — the property is never read. Before flagging a missing override as a bug, trace the full consumption path from where the property is set to where it is used.
8+
9+
**Prefer `padding-inline` shorthand when both edges share the same value:** Splitting into `padding-inline-start`/`padding-inline-end` forces every size override block to set two properties instead of one. Keep the shorthand and use a single override hook (`--swc-badge-padding-inline`) that size blocks can update in one line; asymmetric start-edge logic can override `--swc-badge-padding-inline-start` in the fallback chain.
10+
11+
**Fallback chains can propagate size overrides without duplicating properties:** `padding-inline-start: calc(var(--swc-badge-padding-inline-start, var(--swc-badge-padding-inline, token(...))))` means size overrides only need to set `--swc-badge-padding-inline` and both edges stay in sync, while a `:has()` rule can still override the start edge independently via `--swc-badge-padding-inline-start`.
12+
13+
**Fix proposals must account for all variant states:** A fix that adds a property to size override blocks may break the icon state if that same property is already being set to a different value by a `:has()` rule. Think through the full set of states (no icon, with icon, icon-only) before proposing a change.
14+
15+
## CI / build
16+
17+
**commitlint in this project enforces lowercase subjects:** The `subject-case` rule forbids sentence-case, start-case, pascal-case, and upper-case. Commit subjects must start with a lowercase letter — `fix(badge): correct fallbacks...` not `fix(badge): Correct fallbacks...`.
18+
19+
**Stylelint/prettier rewrites files substantially after commits:** The linter hook may revert manual splits back to shorthands, change default scale tokens, or remove entire CSS patterns. Always re-read the file after a commit before writing memory or validation docs — the on-disk state may differ significantly from what was written.
20+
21+
## File operations
22+
23+
**Update memory/validation docs after linter runs:** If a linter rewrites a component CSS file, any memory files or validation docs written before the lint run may describe a state that no longer exists. Re-read the source file and correct the docs in the same session before context is lost.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
name: session-retrospective
3+
description: Document lessons learned after completing work, especially when the user corrected planning documents or implementation. Creates and maintains a persistent lessons file in .ai/memory/ that future agents read at session start.
4+
---
5+
6+
# Session retrospective
7+
8+
## Mindset
9+
10+
You are a continuous improvement engineer. Every correction the user makes is signal, not noise. Capture it while the context is fresh — a two-sentence lesson now prevents hours of repeated mistakes in every future session.
11+
12+
## When to use
13+
14+
**Triggered by:**
15+
16+
- User corrects your work — wrong path, wrong assumption, wrong approach
17+
- User says "document what you learned", "add to lessons", or "remember this"
18+
- You encounter a tool limitation, surprising behavior, or non-obvious constraint
19+
- End of a session where substantial work was done and corrections were made
20+
21+
**Proactively suggest** when the user corrects the same type of mistake more than once in a session.
22+
23+
## When NOT to use
24+
25+
- Trivial typo fixes with no future relevance
26+
- Corrections that are specific to a one-off task and won't recur
27+
- Preserving project state for continuing work — use `session-handoff` for that
28+
29+
---
30+
31+
## Workflow
32+
33+
### 1. Identify what to capture
34+
35+
For each correction or surprise, ask: **what would have prevented this mistake?**
36+
37+
| What happened | What to document |
38+
| ------------------------------- | --------------------------------------------------- |
39+
| Wrong file path | The correct path and why the wrong one seemed right |
40+
| Wrong tool usage | The correct usage and the constraint |
41+
| Misunderstood project structure | Where things actually live |
42+
| Tool limitation hit | What the tool can't do and the workaround |
43+
| Assumption that didn't hold | The actual rule or constraint |
44+
45+
Skip corrections that are one-offs or already obvious from the error message.
46+
47+
### 2. Check existing lessons first
48+
49+
Read `.ai/memory/lessons.md` before writing. Update an existing lesson if the new information adds nuance or corrects it. Never create a duplicate entry.
50+
51+
### 3. Write to `.ai/memory/lessons.md`
52+
53+
Group lessons by **category**, not by date. Categories:
54+
55+
- **File operations** — tool behavior, read-before-edit, parallel edit failures
56+
- **Path resolution** — relative vs absolute, directory depth, symlinks
57+
- **Project structure** — where things actually live vs where they seem to be
58+
- **Tool limitations** — what tools can/can't do, workarounds
59+
- **CI / build** — what passes/fails, why, which scripts exist
60+
- **Component patterns** — SWC-specific conventions (tags, stories structure, etc.)
61+
- **Agent tooling**`.ai/` rules, `AGENTS.md`, skills behavior, config
62+
63+
Add new categories when none of the above fit.
64+
65+
### 4. Format
66+
67+
Each lesson is **one or two sentences**:
68+
69+
1. **Bold subject** — the trigger condition or context
70+
2. Plain sentence — what to do (or not do)
71+
72+
**Good:**
73+
74+
> **Edit tool requires a prior read**: The Edit tool fails with "file not read yet" if the file wasn't read in the current conversation. Read all files you plan to edit before starting work.
75+
76+
**Bad:**
77+
78+
> We had an issue with editing files.
79+
80+
Lessons should be actionable. A future agent reading them should know exactly what to do differently.
81+
82+
### 5. Keep it scannable
83+
84+
- Max 1–2 sentences per lesson
85+
- Update existing lessons rather than appending duplicates
86+
- If a lesson turns out to be wrong, remove or correct it — stale lessons cause the same problems they were meant to prevent
87+
- Keep the total file under ~100 lines; if it grows past that, consolidate or remove stale entries
88+
89+
---
90+
91+
## Output location
92+
93+
**`.ai/memory/<descriptor>-lessons.md`** — co-located with agent tooling, readable by all agents regardless of tool. Use a descriptor that reflects the theme of the lessons (e.g. `agnostic-lessons.md` for tool-agnostic AI setup work, `migration-lessons.md` for migration-specific patterns). Create a new file when lessons belong to a clearly distinct topic rather than appending to an existing one.
94+
95+
---
96+
97+
## Checklist
98+
99+
- [ ] Lessons are in `.ai/memory/<descriptor>-lessons.md`, not in a session-specific file
100+
- [ ] Each lesson is in the correct category
101+
- [ ] Each lesson is 1–2 sentences and actionable
102+
- [ ] No duplicates — existing entries were checked and updated if needed
103+
- [ ] Stale or incorrect lessons were removed or corrected
104+
105+
---
106+
107+
## Quality gate
108+
109+
A retrospective is complete when:
110+
111+
> Every significant correction from the session is captured as an actionable lesson in the correct category; no duplicates exist; lessons are scannable in under 60 seconds.

0 commit comments

Comments
 (0)