Skip to content

The meta-skill that builds and improves all your skills, including itself. Watches your work sessions (autonomous or human-led), captures patterns, corrections and judgement calls, and turns them into skill improvements and new skill candidates for your review. Practical application of the Augmented Expertise methodology. Open source: CC BY 4.0.

Look up observations by target file too, and survive a first run

Eoghan Henn5e982fb8a668
diff --git a/SKILL.md b/SKILL.md
index 6aeb0f6..388830a 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -267,7 +267,7 @@ for one skill rarely share a name.
**Check for a restatement before writing.** Before creating the file, list
the open observations that name the same target skill (the scan at session
start already holds their titles; otherwise `find observation-log -name
-'*.md' -exec grep -l "skill:.*<bare-name>" {} +`) and read those titles. If the
+'*.md' -exec grep -l -E "^(skill|target_file):.*<bare-name>" {} +`) and read those titles. If the
finding is the same one restated — the same rule, the same failure shape, a
different example — extend the existing entry instead: append the new
instance to its body, add the session to `session_context`, widen `title:`
diff --git a/references/environments.md b/references/environments.md
index 146b76e..7ecf654 100644
--- a/references/environments.md
+++ b/references/environments.md
@@ -166,15 +166,14 @@ first task boundary instead of never.
Loading a skill is not complete until you have queried the observation
log for OPEN observations naming it and read their bodies:
find "[ABSOLUTE PATH]/skill-observations/observation-log" -maxdepth 1 \
- -name '*.md' -exec grep -l "skill:.*<skill-name>" {} +
+ -name '*.md' -exec grep -l -E "^(skill|target_file):.*<skill-name>" {} +
(<skill-name> is the bare name: drop a plugin: prefix, up to the last
colon. A qualified pattern misses every entry filed under the bare name
-and reports a clean zero; the bare one matches both spellings.)
-(Use find, not a bare *.md glob. Under zsh an unmatched glob is an error,
-so on an empty log the command never runs and the enclosing block aborts —
-and 2>/dev/null does not help, because the redirection belongs to a
-command that never starts. This is the first thing that fires on a fresh
-install, in every session, for as long as the log is empty.)
+and reports a clean zero; the bare one matches both spellings. For an
+agent definition or instructions file it is the file name, which the
+target_file: field carries by any path.)
+(Use find, not a bare *.md glob: under zsh an unmatched glob aborts the
+whole block, and on an empty log it is unmatched in every session.)
Apply their insights to the current work — meaning: let them change what
you do in THIS task. Editing the skill file, or writing the rule into any
other file a later session reads, is acting on the observation and waits
@@ -195,7 +194,10 @@ substitute for the skill that owns it.
Where scripts run, the lookup and its checkpoint line are one command:
bash "<skill directory>/scripts/skill-load.sh" "[ABSOLUTE PATH]" <skill-name>
The Skill invocation and that call are ONE batch — emit them together,
-one call per skill loaded, never the call in a later batch.
+one call per skill loaded, never the call in a later batch. On a first
+run the log does not exist yet (step 1 creates it): the call says so and
+exits 0 with no checkpoint line; re-run it once per skill loaded in that
+batch after the Workspace creation command.
The task-observer workspace for this project is:
[ABSOLUTE PATH]
@@ -223,6 +225,9 @@ because only it sees the whole task and its review; a subagent that
notices something worth logging says so in its final report, and the
controller writes it, running the id snippet per write. A start-up rule
in a project file reaches every agent the project ever dispatches.
+Before briefing a delegate under an agent definition or instructions
+file, run the lookup for that file's name; its open entries shape the
+brief.
An observation file comes into being only through
bash "<skill directory>/scripts/new-observation.sh" <slug> "[ABSOLUTE PATH]"
diff --git a/references/observation-log.md b/references/observation-log.md
index d5be763..3b6eae1 100644
--- a/references/observation-log.md
+++ b/references/observation-log.md
@@ -158,7 +158,7 @@ promise about the rest.
| `type` | `open-source` or `internal` (see Taxonomy in the core skill). |
| `skill` | **Always a list**, even with one entry, so no consumer ever branches on string-vs-list. First entry is primary. May be empty. Write each name in its bare form — the part after the last colon of the listed name — and qualify it as `plugin:skill` only where two installed skills share that bare name; a qualified entry is quoted: `["plugin:skill", other-skill]` (below). Bare is the canonical form because it is what writers produce in practice (0 of 40 entries were qualified when the two rules were compared) and one skill in two spellings is two review buckets. Every lookup BY skill name — a grep with a skill-name slot, `scripts/skill-load.sh` — reduces a `plugin:name` to the part after the last colon before matching: the bare pattern matches both spellings, while a qualified one misses every entry filed under the bare name and returns a clean zero. |
| `proposes_skill` | List of new-skill candidates by working name. Independent of `skill`; either may be empty, both may be filled. |
-| `target_file` | List of paths, for observations whose right home is not a skill: an instructions file, a memory note, an agent brief, the register a routine reads. Name the file the fix will actually be written to, so a review can go there instead of remapping the entry onto the nearest skill. Measured on a first review of 27 legacy entries: 15 named a non-skill in `skill:` ("browser verification protocol", "documentation hygiene") and every one had to be resolved to a path by hand before the review could start. |
+| `target_file` | List of paths, for observations whose right home is not a skill: an instructions file, a memory note, an agent brief, the register a routine reads. Name the file the fix will actually be written to, so a review can go there instead of remapping the entry onto the nearest skill. Every lookup by name reads this field beside `skill:` and matches on the last path segment, so `scripts/skill-load.sh reviewer.md` (and the activation grep) finds an entry filed under that file by any path. Measured on a first review of 27 legacy entries: 15 named a non-skill in `skill:` ("browser verification protocol", "documentation hygiene") and every one had to be resolved to a path by hand before the review could start. |
| `siblings_checked` | **Mandatory, never blank.** Records that the sibling check happened and what it concluded: the family name, the members evaluated, and the verdict per member (propagated / excluded). Every **exclusion** carries its ground — the file and section (or line) read in that sibling showing it does not apply — or the literal token `assumed`; inclusions need no ground, because including a sibling is the safe error. An `assumed` exclusion is a review item, not a settled verdict. `none` only where the target belongs to no family. Missing or empty = logged without a sibling check, and reviews count it as such. |
| `area` | The part of the skill or workflow concerned. |
| `date` | Date logged, `YYYY-MM-DD`. |
diff --git a/scripts/skill-load.sh b/scripts/skill-load.sh
index 5339b9b..bb3cf06 100755
--- a/scripts/skill-load.sh
+++ b/scripts/skill-load.sh
@@ -10,11 +10,18 @@
# holds skill-observations/. Never resolved from the cwd;
# the path may contain spaces.
# <skill-name> the skill whose Skill invocation rides in THIS batch, as
-# the listing shows it (`plugin:name` allowed). The match
-# is on the bare name — the part after the last `:` — on
-# both sides, so a plugin-qualified listing finds entries
-# that name the bare skill and vice versa; never on a
-# prefix: `foo` does not match `foo-extras`.
+# the listing shows it (`plugin:name` allowed), OR the
+# file name of an agent definition or instructions file
+# a delegate is about to be briefed under (`reviewer.md`;
+# a path is reduced to its file name). The match is on
+# the bare name — the part after the last `:` and the
+# last `/` — on both sides, against the `skill:` AND
+# `target_file:` fields, so a plugin-qualified listing
+# finds entries that name the bare skill and vice versa,
+# and a file name finds the entries filed under that
+# file by any path; never on a prefix: `foo` does not
+# match `foo-extras`, and `reviewer` does not match
+# `reviewer.md`.
#
# Prints, on stdout: one line `<skill-name>: N open observations`, then the
# matching file names, one per line (read their bodies next). Appends one
@@ -22,14 +29,19 @@
# YYYY-MM-DD HH:MM loaded <skill-name> — N open observations
#
# Exit status:
-# 0 the lookup ran (N may be 0)
+# 0 the lookup ran (N may be 0) — or no log exists yet under an existing
+# root (a first run: the load batch precedes Session Start step 1,
+# which creates the log). That case prints one NOTE line naming the
+# missing log, writes nothing (there is no checkpoints.log to write
+# to) and is not "0 open": re-run the lookup once for each skill
+# loaded in that batch after the Workspace creation command has run
# 1 LOOKUP BROKEN — entries exist but no header parsed, or the lookup
# stage itself exited with an error; nothing is written to
# checkpoints.log, because "0 open" from a command that read nothing
# is the one result nobody questions
-# 2 refused: missing arguments, a relative root, a root without
-# skill-observations/, or a skill name with characters outside
-# [A-Za-z0-9:._-]
+# 2 refused: missing arguments, a relative root, a root that does not
+# exist, a pre-3.0 log.md with no observation-log/ beside it, or a
+# skill name with characters outside [A-Za-z0-9:._/-]
#
# Why a script: a rule about what a tool batch must CONTAIN cannot be
# enforced by prose inside the thing the batch loads — the agent reads the
@@ -60,22 +72,36 @@ case "$root" in
(*) echo "workspace root must be an ABSOLUTE path, never relative to the cwd: got '$root'" >&2; exit 2 ;;
esac
case "$name" in
- (*[!A-Za-z0-9:._-]*) echo "skill name may hold only [A-Za-z0-9:._-]: got '$name'" >&2; exit 2 ;;
+ (*[!A-Za-z0-9:._/-]*) echo "skill name may hold only [A-Za-z0-9:._/-]: got '$name'" >&2; exit 2 ;;
esac
# Every expansion of $root and $d stays double-quoted: the pinned path
# routinely contains a space.
d="$root/skill-observations/observation-log"
if [ ! -d "$d" ]; then
- echo "no observation log at '$d' — run the Workspace creation command first" >&2; exit 2
+ # A missing log under a missing root is a wrong pin; under a pre-3.0
+ # log.md it is an unmigrated install; under an existing root it is the
+ # first run, where this call rides in the batch BEFORE step 1 creates
+ # the log — reported, not refused, so the first load is not a failure
+ # and the re-run after step 1 writes the checkpoint line.
+ if [ ! -d "$root" ]; then
+ echo "workspace root does not exist: '$root' — check the pinned path" >&2; exit 2
+ fi
+ if [ -e "$root/skill-observations/log.md" ]; then
+ echo "LEGACY log.md under '$root/skill-observations' and no observation-log/ — run the migration (references/migration.md) first" >&2; exit 2
+ fi
+ echo "NOTE: $name: no observation log yet at '$d' — a first run, before Session Start step 1 creates it; not 0 open. Re-run this lookup once for each skill loaded in this batch after the Workspace creation command"
+ exit 0
fi
# One awk over every entry. Per file: H <file> when the header closes (the
# parse count), M <file> when the header names the skill AND is open — the
# review's OPEN set: any status other than actioned, declined, superseded or
-# parked, a missing status included. `skill:` is read in all three shapes the log uses: an inline
-# [a, "b"] list, a plain scalar, and a block list of `- a` lines below it.
-prog='function bare(t) { sub(/.*:/, "", t); return t }
+# parked, a missing status included. `skill:` and `target_file:` are read in
+# all three shapes the log uses: an inline [a, "b"] list, a plain scalar,
+# and a block list of `- a` lines below it. bare() strips a plugin
+# qualifier and a path, so both fields compare on the last segment.
+prog='function bare(t) { sub(/.*:/, "", t); sub(/.*\//, "", t); return t }
function tok(t) {
gsub(/^[[:space:]"\047]+|[[:space:]"\047]+$/, "", t)
return t != "" && bare(t) == bare(want)
@@ -83,7 +109,7 @@ prog='function bare(t) { sub(/.*:/, "", t); return t }
FNR == 1 { fm = 0; sk = 0; rs = 0; inl = 0; sub(/^\357\273\277/, "")
if ($0 ~ /^---[[:space:]]*$/) { fm = 1; next } else nextfile }
fm && /^---[[:space:]]*$/ { print "H " FILENAME; if (sk && !rs) print "M " FILENAME; nextfile }
- fm && /^skill:/ { v = $0; sub(/^skill:[[:space:]]*/, "", v); sub(/[[:space:]]+#.*$/, "", v)
+ fm && /^(skill|target_file):/ { v = $0; sub(/^(skill|target_file):[[:space:]]*/, "", v); sub(/[[:space:]]+#.*$/, "", v)
inl = (v ~ /^[[:space:]]*$/); gsub(/[][]/, "", v)
n = split(v, a, ","); for (i = 1; i <= n; i++) if (tok(a[i])) sk = 1
next }
diff --git a/scripts/validate-skill-bundle.py b/scripts/validate-skill-bundle.py
index ef8689d..e61cba1 100644
--- a/scripts/validate-skill-bundle.py
+++ b/scripts/validate-skill-bundle.py
@@ -1202,35 +1202,49 @@ def scan_case(scenario, pass_root):
# scripts/skill-load.sh, the per-skill lookup run beside each Skill
# invocation: (name, skill argument, absolute root?, exit status, stdout
-# substring, checkpoint lines written). The fixture holds one match, one
-# prefix-only name, one closed entry and one body-only mention.
+# substring, checkpoint lines written[, "nolog"]). The fixture holds one
+# match, one prefix-only name, one closed entry, one body-only mention and
+# two target_file entries; "nolog" runs it against a root with no
+# skill-observations/ at all (the first run, before step 1).
LOAD_SCRIPT = pathlib.Path(__file__).resolve().parent / "skill-load.sh"
LOAD_FIXTURES = [
("exact name, open only, frontmatter only", "foo", True, 0, "foo: 1 open observations\n0001-a.md", 1),
("plugin-qualified listing finds the bare-name entry", "plug:foo", True, 0,
"plug:foo: 1 open observations\n0001-a.md", 1),
("relative root: refused, nothing written", "foo", False, 2, "", 0),
+ ("a file name finds the target_file entry by its last segment", "reviewer.md", True, 0,
+ "reviewer.md: 1 open observations\n0005-e.md", 1),
+ ("the bare skill name does not match the file name", "reviewer", True, 0,
+ "reviewer: 1 open observations\n0006-f.md", 1),
+ ("no log yet: one NOTE line, exit 0, nothing written", "foo", True, 0,
+ "NOTE: foo: no observation log yet at ", 0, "nolog"),
]
-def load_case(skill, absolute):
+def load_case(skill, absolute, scenario=""):
import os
import subprocess
with tempfile.TemporaryDirectory() as tmp:
root = pathlib.Path(tmp) / "work space"
log = root / "skill-observations" / "observation-log"
- log.mkdir(parents=True)
ck = root / "skill-observations" / "checkpoints.log"
- ck.write_text("", encoding="utf-8")
- for f, head, body in [("0001-a.md", "skill: [foo, bar]\nstatus: open", ""),
- ("0002-b.md", "skill: [foo-extras]\nstatus: open", ""),
- ("0003-c.md", "skill: foo\nstatus: actioned", ""),
- ("0004-d.md", "skill: [bar]\nstatus: open", "skill: foo\n")]:
- (log / f).write_text(f"---\nid: 1\n{head}\n---\n{body}", encoding="utf-8")
+ if scenario == "nolog":
+ root.mkdir(parents=True)
+ else:
+ log.mkdir(parents=True)
+ ck.write_text("", encoding="utf-8")
+ for f, head, body in [("0001-a.md", "skill: [foo, bar]\nstatus: open", ""),
+ ("0002-b.md", "skill: [foo-extras]\nstatus: open", ""),
+ ("0003-c.md", "skill: foo\nstatus: actioned", ""),
+ ("0004-d.md", "skill: [bar]\nstatus: open", "skill: foo\n"),
+ ("0005-e.md", "skill: []\ntarget_file: [.claude/agents/reviewer.md]\nstatus: open", ""),
+ ("0006-f.md", "skill: [reviewer]\nstatus: open", "")]:
+ (log / f).write_text(f"---\nid: 1\n{head}\n---\n{body}", encoding="utf-8")
arg = str(root) if absolute else os.path.relpath(root, tmp)
r = subprocess.run(["bash", str(LOAD_SCRIPT), arg, skill], cwd=tmp, capture_output=True,
text=True, encoding="utf-8", errors="replace")
- return r.returncode, r.stdout, len(ck.read_text(encoding="utf-8").splitlines())
+ written = len(ck.read_text(encoding="utf-8").splitlines()) if ck.is_file() else 0
+ return r.returncode, r.stdout, written
# scripts/migrate-log.py, the pre-3.0 log converter: (name, legacy entry's
@@ -1459,8 +1473,8 @@ def selftest():
ok = subprocess.run(["bash", "-n", str(LOAD_SCRIPT)]).returncode == 0
bad += not ok; total += 1
print(f"{'ok ' if ok else 'FAIL'} skill-load script: bash -n passes")
- for name, skill, absolute, want_rc, want_out, want_ck in LOAD_FIXTURES:
- rc, out, ck = load_case(skill, absolute)
+ for name, skill, absolute, want_rc, want_out, want_ck, *scenario in LOAD_FIXTURES:
+ rc, out, ck = load_case(skill, absolute, *scenario)
ok = rc == want_rc and want_out in out and ck == want_ck
bad += not ok; total += 1
print(f"{'ok ' if ok else 'FAIL'} skill-load script: {name}"