Skip to content

Commit 476bfd1

Browse files
Agent skills: emphasize generalization and self-containment in lessons and skill updates (#1810)
* Initial plan * feat: put more emphasis on generalizing lessons and skill content - usethis-lesson-create v1.0 → v1.1: add "Self-containment and abstraction" section; strengthen "Generalise the principle" step; update lesson template; add abstraction examples table - usethis-skills-modify v1.5 → v1.6: add "Generalise the instruction" procedure step; add "Generalising incoming instructions" section with examples table; add "Never reference memories" content guideline Resolves #1820 Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/a66b4b24-94c2-491f-ac7c-dd02c6b3ca53 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent ad8f2b7 commit 476bfd1

2 files changed

Lines changed: 65 additions & 8 deletions

File tree

.agents/skills/usethis-lesson-create/SKILL.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Create a lesson from a development difficulty, covering root cause
44
compatibility: usethis, GitHub, gh CLI
55
license: MIT
66
metadata:
7-
version: "1.0"
7+
version: "1.1"
88
---
99

1010
# Creating a Lesson
@@ -26,6 +26,32 @@ A well-formed lesson answers:
2626
2. **Why** it went wrong (the root cause, not the symptom).
2727
3. **What principle** this reveals (something actionable for the future).
2828

29+
## Self-containment and abstraction
30+
31+
Lessons must stand alone. A lesson is read in future sessions with no access to prior
32+
context, stored memories, or conversation history. Therefore:
33+
34+
- **Never reference memories.** Do not write phrases like "as noted in a previous
35+
session", "per the stored memory about X", or "see the earlier lesson on Y". A reader
36+
with no history must be able to understand and apply the lesson without looking anything
37+
up.
38+
- **Never name specific code objects unless they are the subject.** If the principle is
39+
about a pattern, name the pattern — not the exact function, class, or file where you
40+
first encountered it. Specific names become stale and narrow the lesson's applicability.
41+
- **State principles at the right level of abstraction.** A good principle applies to an
42+
entire class of situations. Ask yourself: would this guidance still be useful if the
43+
specific file or function that triggered it were renamed or removed? If not, generalise
44+
further.
45+
46+
### Examples of abstraction
47+
48+
| Too specific | Better |
49+
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
50+
| Always call `clear_functools_caches()` after adding `@functools.cache`. | Whenever a caching decorator is added, ensure the cache is cleared in tests. |
51+
| `validate_or_raise` accepts `err=`, not `error_cls`. | Validation helpers often have specific argument conventions — check the signature before use. |
52+
| Update `AGENTS.md` when adding a skill to `.agents/skills/`. | Keep all registry files in sync whenever a new entry is added to a tracked directory. |
53+
| Put new helpers in `src/mypackage/_utils/helpers.py`. | Place new helpers near their primary caller, following the project's module layout conventions. |
54+
2955
## When to create a lesson
3056

3157
Create a lesson whenever you:
@@ -45,7 +71,10 @@ cause is self-evident and offers no transferable principle.
4571
2. **Perform root cause analysis** — ask "why?" iteratively to move from the
4672
symptom to an underlying cause. See the section below.
4773
3. **Generalise the principle** — restate the root cause as a transferable rule or
48-
heuristic that applies beyond this specific situation.
74+
heuristic that applies beyond this specific situation. Write it so it remains useful
75+
even if the exact code, file, or function name changes. Avoid naming specific
76+
implementation details unless the principle is truly about that specific thing.
77+
See the "Self-containment and abstraction" section above for guidance.
4978
4. **Fill in the lesson template** — see the template below.
5079
5. **File as a GitHub issue** using the `usethis-github-issue-create` skill, with
5180
label `agent` and any other relevant labels (e.g. `bug`, `documentation`).
@@ -94,7 +123,8 @@ cause, not the symptom.>
94123

95124
<A transferable rule or heuristic — written so it applies beyond this specific
96125
situation. Phrase it as actionable guidance: "Always ...", "Never ...", "When X,
97-
do Y ...".>
126+
do Y ...". Avoid naming specific functions, classes, or files unless the principle is
127+
truly about that specific thing. Do not reference memories or prior sessions.>
98128

99129
## Resolution
100130

.agents/skills/usethis-skills-modify/SKILL.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Enforce version bumping, scope checking, and content quality guide
44
compatibility: usethis, agent skills, markdown
55
license: MIT
66
metadata:
7-
version: "1.5"
7+
version: "1.6"
88
---
99

1010
# Modifying Agent Skills
@@ -14,9 +14,35 @@ metadata:
1414
When modifying any `SKILL.md` file in `.agents/skills/`:
1515

1616
1. **Check scope** — verify the new content belongs in this skill (see "Before modifying: check scope" below).
17-
2. Make the necessary content changes to the skill.
18-
3. Increment the version number in the YAML frontmatter `metadata.version` field.
19-
4. Verify the YAML frontmatter is valid (all required fields present, version is quoted).
17+
2. **Generalise the instruction** — if the instruction you received is highly specific (names an exact function, file, or code object), lift it to a transferable principle before writing the skill content. See "Generalising incoming instructions" below.
18+
3. Make the necessary content changes to the skill.
19+
4. Increment the version number in the YAML frontmatter `metadata.version` field.
20+
5. Verify the YAML frontmatter is valid (all required fields present, version is quoted).
21+
22+
## Generalising incoming instructions
23+
24+
You will often receive instructions that are phrased in terms of a specific situation:
25+
"add guidance about function X", "mention that file Y must be updated", or "note that
26+
class Z behaves this way". Before writing this into a skill, lift the instruction to a
27+
more abstract principle.
28+
29+
Ask: **What general rule does this specific case illustrate?** A skill should remain
30+
useful as the codebase evolves. If the specific function, file, or class mentioned in
31+
the instruction were renamed or removed, would the guidance still be relevant? If not,
32+
rewrite it so it would be.
33+
34+
| Specific instruction received | Generalised skill content |
35+
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36+
| "Add a note that `foo_helper()` must be called before `bar()`." | "Certain setup steps must be completed before the main operation — check the API contract for ordering requirements." |
37+
| "Note that `config.toml` must be updated when adding a new flag." | "When adding a feature that introduces new configuration, update all files that declare or document available options." |
38+
| "Warn that `TypeAdapter.validate_python` is banned, use `validate_or_raise`." | "Some standard-library or third-party APIs may be banned by project convention — consult the linter configuration or project documentation before reaching for them." |
39+
40+
Avoid adding guidance that:
41+
42+
- Names specific functions, classes, or files unless the principle is **only** about
43+
that specific thing (e.g. a skill about a single tool's CLI interface).
44+
- Reads like a changelog or incident report ("we discovered that X did Y").
45+
- Would become incorrect or confusing if the named entity were refactored.
2046

2147
## Before modifying: check scope
2248

@@ -67,7 +93,8 @@ When modifying skill content, maintain these principles:
6793

6894
- **Don't make descriptions prescriptive.** If you update the `description` field in the YAML frontmatter, don't use commanding language like "ALWAYS use when..." — describe what the skill covers in neutral terms. See the `usethis-skills-create` skill for detailed description-writing guidelines.
6995
- **Describe procedures, not state.** Skills should explain how to approach situations, not describe the current state of the codebase. State descriptions become outdated; procedures remain valid. See the `usethis-skills-create` skill for detailed guidance.
70-
- **Keep content general.** Write instructions that remain valid as the codebase evolves. Avoid embedding specific file paths, class names, or constants unless strictly necessary.
96+
- **Keep content general.** Write instructions that remain valid as the codebase evolves. Avoid embedding specific file paths, class names, or constants unless strictly necessary. See "Generalising incoming instructions" above.
97+
- **Never reference memories.** Skill content is read with no access to agent session history or stored memories. Do not write phrases like "as noted in a previous session" or "per the stored memory about X". Everything the reader needs must be present in the skill itself.
7198
- **Be concise.** Only include information the agent doesn't already know. If a paragraph doesn't justify its token cost, remove it.
7299
- **Avoid time-sensitive information.** Don't include current version numbers, file counts, or lists that grow over time.
73100
- **Use consistent terminology.** Don't introduce synonyms for concepts that already have established terms in the skill.

0 commit comments

Comments
 (0)