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.
Python agent-skillsai-skillsaugmented-expertiseawesome-skillsclaudeclaude-codeclaude-code-skillclaude-code-skillsclaude-coworkclaude-skillsmeta-skillrebelyticsskill-automationskill-builderskill-creationskill-improvementskill-managementskills
Session-start scan: ship it as scripts/session-start-scan.sh
Eoghan Hennd18d4e09cb8e
diff --git a/README.md b/README.mdindex 71e7987..a4ab7d7 100644--- a/README.md+++ b/README.md@@ -71,7 +71,7 @@ One honest boundary: the formal observation log and review cycle pay off most as## Installation-The skill is a small bundle: `SKILL.md`, the files in `references/` that are loaded on demand (this keeps the always-loaded part lean), and three helper scripts in `scripts/`. Installing only SKILL.md works, but runs degraded and isn't recommended — the skill will tell you which files are missing.+The skill is a small bundle: `SKILL.md`, the files in `references/` that are loaded on demand (this keeps the always-loaded part lean), and four helper scripts in `scripts/`. Installing only SKILL.md works, but runs degraded and isn't recommended — the skill will tell you which files are missing.**Get the files:** download the `.skill` bundle attached to the latest release, or download the repo as a ZIP (Code → Download ZIP) / clone it and keep `SKILL.md`, `references/` and `scripts/` together.diff --git a/SKILL.md b/SKILL.mdindex 875dc94..e74ac2c 100644--- a/SKILL.md+++ b/SKILL.md@@ -140,7 +140,7 @@ skill" (some upload paths keep only `SKILL.md`); its episodes do not run.2. **Scan.** Read only the frontmatter of each file in `observation-log/`— the header block between the first two `---` lines, never the bodies— and build awareness from `status`, `skill`, `proposes_skill` and- `title`, and the active principles' headings, which the snippet prints+ `title`, and the active principles' headings, which the scan prints(`principles=` in the checkpoint line). Hold them in awareness, don'tsurface unprompted. Frontmatter-only is the whole point of the per-fileformat: the scan stays cheap once hundreds of observations exist.@@ -151,41 +151,17 @@ skill" (some upload paths keep only `SKILL.md`); its episodes do not run.satisfy the per-skill check").**An empty scan in a log known to be non-empty is a broken command- until proven otherwise** — the snippet's guard halts on it. When the guard- fires, or before adapting the snippet, load `references/observation-log.md`+ until proven otherwise** — the script's guard halts on it. When the guard+ fires, or before adapting the scan, load `references/observation-log.md`("An empty scan over a non-empty log is a broken command").```bash- d="[ABSOLUTE PATH]/skill-observations/observation-log" # the pinned workspace path — re-derive in EVERY call, never relative to the cwd; run under bash, not sh- n=$(find "[ABSOLUTE PATH]/skill-observations/observation-log" -maxdepth 1 -name '[0-9]*.md' ! -empty | wc -l | tr -d ' ') # literal path: independent of $d; numbered, non-empty: what the parse can read- parsed=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) nextfile; next} fm && /^---[[:space:]]*$/ {print FILENAME; nextfile}' {} + | wc -l | tr -d ' ')- sus='FNR==1 {sub(/^\357\273\277/, ""); fm = (/^---[[:space:]]*$/ ? 1 : 0); if (!fm) nextfile; next}- fm && /^---[[:space:]]*$/ {fm=0; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*[^"\047[{|>#&![:space:]].*: / {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*("([^"\\]|\\.)*"[[:space:]]*[^[:space:]#]|\047([^\047]|\047\047)*\047([[:space:]]+[^[:space:]#]|[^[:space:]#\047]))/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*[`@%]/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*"([^"\\]|(\\[0abtnvfre \t\r"\/\\N_LP]|\\x[[:xdigit:]][[:xdigit:]]|\\u[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]|\\U[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]))*\\([^0abtnvfre \t\r"\/\\N_LPxuU]|x([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]])|u([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]])|U([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]))/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+\[/ {v=$0; sub(/^[a-z_]+:[ ]+/,"",v); gsub(/"([^"\\]|\\.)*"/,"",v); gsub(/\047[^\047]*\047/,"",v); sub(/[[:space:]]#.*/,"",v); if (v ~ /:/) {print FILENAME; nextfile}}' # no literal {} in the program: find -exec … {} + would replace it- suspect=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ') # invalid YAML by shape: unquoted ": ", text after a closing quote, a value opening with ` @ %, an undefined escape, a colon in an unquoted list entry- a_sus=0; [ -d "$d/archive" ] && a_sus=$(LC_ALL=C find "$d/archive" -maxdepth 1 -name '*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ') # archive/ may not exist yet- p="[ABSOLUTE PATH]/skill-observations/cross-cutting-principles.md"; pa='/^(\140\140\140|~~~)/ {f=!f} f {next} /^## Active Principles/ {a=1; h=1; next} a && /^## / {a=0}' # a fenced template is not a principle- pr=absent; [ -f "$p" ] && pr=$(awk "$pa"' a && /^### / {n++} END {print (h ? n+0 : "unparsed")}' "$p")- [ "$pr" = unparsed ] && echo "NOTE: the principles file has no '## Active Principles' heading — 'could not parse', not 'no principles'; read it directly"- if [ "$n" -gt 0 ] && [ "$parsed" -eq 0 ]; then echo "SCAN COMMAND BROKEN — $n files present, 0 headers parsed"; exit 1; fi; lost=$( { find "$d" -maxdepth 1 -name '[0-9]*.md' -empty; LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' ! -empty -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); if (!/^---[[:space:]]*$/) print FILENAME; nextfile}' {} +; } | sed 's|.*/||' | LC_ALL=C sort | tr '\n' ' '); [ -n "$lost" ] && echo "LOST ENTRIES — no header, an interrupted write; report each, never reuse or delete: $lost"- [ "$parsed" -lt "$n" ] && echo "NOTE: $((n - parsed)) of $n headers did not parse (no opening or no closing ---):" && LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {if (NR>1 && fm) print f; f=FILENAME; sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print f; nextfile}; next} fm && /^---[[:space:]]*$/ {fm=0; nextfile} END {if (fm) print f}' {} +- [ "$suspect" -gt 0 ] || [ "$a_sus" -gt 0 ] && echo "NOTE: $suspect of $n headers (and $a_sus in archive/) look like invalid YAML (an unquoted ': ', text after a closing quote, a value opening with a backtick, @ or %, an undefined escape, a colon in an unquoted list entry) — quote or fix them (File format)"- printf 'files: %s parsed: %s suspect (awk, a floor): %s archive-suspect: %s\n' "$n" "$parsed" "$suspect" "$a_sus"- printf '%s [%s] session-start scan: files=%s parsed=%s principles=%s\n' "$(date '+%F %H:%M')" "${PWD##*/}" "$n" "$parsed" "$pr" \- >> "[ABSOLUTE PATH]/skill-observations/checkpoints.log" # date+time+source: one line per session, not per day- find "$(dirname "[ABSOLUTE PATH]")" -maxdepth 3 -type d -path '*/skill-observations/observation-log' 2>/dev/null | LC_ALL=C sort | while IFS= read -r o; do printf '%s=%s\n' "${o%/skill-observations/observation-log}" "$(find "$o" -maxdepth 1 -name '[0-9]*.md' | wc -l | tr -d ' ')"; done | awk '{s = s " " $0} END {print "logs under the parent (report; never consolidate from here):" s}'- [ -f "$p" ] && awk "$pa"' a && /^### / {sub(/\r$/, ""); print}' "$p" # the active principles' headings: content, so it prints with the headers below- ( export LC_ALL=C; [ "$n" -eq 0 ] || { cd "$d" && awk 'FNR==1 && NR>1 && fm {print "---"}- FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print "---"; nextfile}; next}- fm && /^---[[:space:]]*$/ {fm=0; print "---"; nextfile}- fm- END {if (fm) print "---"}' [0-9]*.md; } ) # LAST: content print, the only half a classifier can refuse; one awk for the whole set+ bash "<skill directory>/scripts/session-start-scan.sh" "[ABSOLUTE PATH]"```+ `scripts/session-start-scan.sh` is the scan (`<skill directory>`: the one+ holding this file); review what it runs and prints there, line by line.+**Only the print can be refused, so it runs last** — a refused print isnever an empty log: load `references/observation-log.md` ("A refusedprint is not an empty log") before moving either half.diff --git a/USER-GUIDE.md b/USER-GUIDE.mdindex 26d9a43..74a8e59 100644--- a/USER-GUIDE.md+++ b/USER-GUIDE.md@@ -10,7 +10,7 @@ The rest of this user guide focusses on Claude and specifically Claude Cowork, b## Where the skill runs-The skill is a multi-file bundle: `SKILL.md`, a `references/` folder that is loaded on demand, and a `scripts/` folder with three small helpers (the pre-3.0 log migration, the observation-file creator and the bundle validation gate). To install it, put all three into one folder, zip that folder, and upload it via Settings → Customize in your Claude account. Uploading the bare SKILL.md alone results in a degraded install — the skill still works, but will tell you which files are missing, and the automatic upgrade from a pre-3.0 log won't run without `scripts/` (see the Installation section of the readme for other environments).+The skill is a multi-file bundle: `SKILL.md`, a `references/` folder that is loaded on demand, and a `scripts/` folder with four small helpers (the pre-3.0 log migration, the observation-file creator, the session-start scan and the bundle validation gate). To install it, put all three into one folder, zip that folder, and upload it via Settings → Customize in your Claude account. Uploading the bare SKILL.md alone results in a degraded install — the skill still works, but will tell you which files are missing, and the automatic upgrade from a pre-3.0 log and the session-start scan won't run without `scripts/` (see the Installation section of the readme for other environments).Once you've uploaded the skill, it's available in all chats (web interface, mobile app, desktop app) and also in the Cowork and Code tabs of the desktop app. Its full potential can be exploited in Cowork tasks and Code sessions.diff --git a/references/environments.md b/references/environments.mdindex e148106..1e5b64c 100644--- a/references/environments.md+++ b/references/environments.md@@ -282,12 +282,13 @@ than consolidating on your own judgement, because one plural case islegitimate (see the multi-log block in `weekly-review.md`).**The session-start scan lists the neighbours on every run.** One line of-the scan snippet finds every `skill-observations/observation-log/` up to-three levels under the pinned root's parent and prints each with its file-count — `logs under the parent (…): /a/proj=157 /a/other=19`. One entry-is the ordinary case. Several are either shards or the legitimate plural-case, and the line cannot tell which: report it in one line, route to-"Several observation logs on one machine" in `weekly-review.md`, and never+the scan (`scripts/session-start-scan.sh`) finds every+`skill-observations/observation-log/` up to three levels under the+pinned root's parent and prints each with its file count — `logs under+the parent (…): /a/proj=157 /a/other=19`. One entry is the ordinary+case. Several are either shards or the legitimate plural case, and the+line cannot tell which: report it in one line, route to "Several+observation logs on one machine" in `weekly-review.md`, and neverconsolidate from the scan. The probe is bounded by the parent's depth-3tree, not by any log's size; an empty line means the probe could not readthe parent, since the pinned log itself is always under it.@@ -950,13 +951,15 @@ and the same command run from a file arrives exact. A body written throughthat shell loses one backslash of every `\\`, and an inline snippet thatcarries `\\` runs altered: the session-start scan's `suspect` program,halved, is rejected by gawk, mawk and BWK awk, so the count reads 0 with-an error on stderr. Test a host once with `printf '%s\n' 'a\\b' | od -c`:-two backslashes in the output mean the transport is exact. Where it is-not, write observation bodies and any other content holding backslashes-with the editing tool, and run a snippet that carries `\\` from a file-written with the editing tool (`bash <file>`). Very long inline commands-have also been reported cut on the same transport, so keep inline commands-short and put long content in files.+an error on stderr — why the scan ships as `scripts/session-start-scan.sh`,+whose one-line invocation carries no backslash. Test a host once with+`printf '%s\n' 'a\\b' | od -c`: two backslashes in the output mean the+transport is exact. Where it is not, write observation bodies and any+other content holding backslashes with the editing tool, and run a+snippet that carries `\\` from a file written with the editing tool+(`bash <file>`). Very long inline commands have also been reported cut on+the same transport, so keep inline commands short and put long content in+files.**A byte order mark from Windows PowerShell.** PowerShell 5.1 writes UTF-8with a BOM (`Set-Content -Encoding UTF8`, `Out-File -Encoding utf8`).@@ -1251,7 +1254,8 @@ This skill consists of `SKILL.md`, the reference files it lists(`weekly-review.md`, `skill-authoring.md`, `environments.md`,`observation-log.md`, `signals.md`, `migration.md`,`starter-principles.md`) and `scripts/migrate-log.py`,-`scripts/new-observation.sh` and `scripts/validate-skill-bundle.py`. If a referenced+`scripts/new-observation.sh`, `scripts/session-start-scan.sh` and+`scripts/validate-skill-bundle.py`. If a referencedfile is missing, the install isincomplete: proceed using the rules in `SKILL.md`, tell the user whichfiles are missing, and point them to the full bundle at the canonicaldiff --git a/references/observation-log.md b/references/observation-log.mdindex 8041657..e2f69d9 100644--- a/references/observation-log.md+++ b/references/observation-log.md@@ -161,8 +161,8 @@ command it rides inside succeed.the derivation stops before any file exists, and an adapted snippet mayfail more quietly than that. A `bash` code fence states that to a humanreader and to nothing else, so invoke the snippets with bash explicitly; a-block that happens to be POSIX-safe too (the session-start scan, the-sweep) is incidental, not a promise about the rest.+block that happens to be POSIX-safe too (the sweep) is incidental, not a+promise about the rest.## Frontmatter fields@@ -376,40 +376,9 @@ run.)Read only the frontmatter — the header block between the first two `---`lines — never the bodies. This is what keeps the session-start scan andthe review's work-queue pass cheap once hundreds of observations exist.-The core skill's Session Start Protocol holds the authoritative copy of-this snippet; the copy below is reproduced for reading in context, and if-the two ever disagree, the core wins:--```bash-d="[ABSOLUTE PATH]/skill-observations/observation-log" # the pinned workspace path — re-derive in EVERY call, never relative to the cwd; run under bash, not sh-n=$(find "[ABSOLUTE PATH]/skill-observations/observation-log" -maxdepth 1 -name '[0-9]*.md' ! -empty | wc -l | tr -d ' ') # literal path: independent of $d; numbered, non-empty: what the parse can read-parsed=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) nextfile; next} fm && /^---[[:space:]]*$/ {print FILENAME; nextfile}' {} + | wc -l | tr -d ' ')-sus='FNR==1 {sub(/^\357\273\277/, ""); fm = (/^---[[:space:]]*$/ ? 1 : 0); if (!fm) nextfile; next}- fm && /^---[[:space:]]*$/ {fm=0; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*[^"\047[{|>#&![:space:]].*: / {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*("([^"\\]|\\.)*"[[:space:]]*[^[:space:]#]|\047([^\047]|\047\047)*\047([[:space:]]+[^[:space:]#]|[^[:space:]#\047]))/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*[`@%]/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*"([^"\\]|(\\[0abtnvfre \t\r"\/\\N_LP]|\\x[[:xdigit:]][[:xdigit:]]|\\u[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]|\\U[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]))*\\([^0abtnvfre \t\r"\/\\N_LPxuU]|x([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]])|u([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]])|U([^[:xdigit:]]|[[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]|[[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]][^[:xdigit:]]))/ {print FILENAME; nextfile}- fm && /^[a-z_]+:[ ]+\[/ {v=$0; sub(/^[a-z_]+:[ ]+/,"",v); gsub(/"([^"\\]|\\.)*"/,"",v); gsub(/\047[^\047]*\047/,"",v); sub(/[[:space:]]#.*/,"",v); if (v ~ /:/) {print FILENAME; nextfile}}' # no literal {} in the program: find -exec … {} + would replace it-suspect=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ') # invalid YAML by shape: unquoted ": ", text after a closing quote, a value opening with ` @ %, an undefined escape, a colon in an unquoted list entry-a_sus=0; [ -d "$d/archive" ] && a_sus=$(LC_ALL=C find "$d/archive" -maxdepth 1 -name '*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ') # archive/ may not exist yet-p="[ABSOLUTE PATH]/skill-observations/cross-cutting-principles.md"; pa='/^(\140\140\140|~~~)/ {f=!f} f {next} /^## Active Principles/ {a=1; h=1; next} a && /^## / {a=0}' # a fenced template is not a principle-pr=absent; [ -f "$p" ] && pr=$(awk "$pa"' a && /^### / {n++} END {print (h ? n+0 : "unparsed")}' "$p")-[ "$pr" = unparsed ] && echo "NOTE: the principles file has no '## Active Principles' heading — 'could not parse', not 'no principles'; read it directly"-if [ "$n" -gt 0 ] && [ "$parsed" -eq 0 ]; then echo "SCAN COMMAND BROKEN — $n files present, 0 headers parsed"; exit 1; fi; lost=$( { find "$d" -maxdepth 1 -name '[0-9]*.md' -empty; LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' ! -empty -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); if (!/^---[[:space:]]*$/) print FILENAME; nextfile}' {} +; } | sed 's|.*/||' | LC_ALL=C sort | tr '\n' ' '); [ -n "$lost" ] && echo "LOST ENTRIES — no header, an interrupted write; report each, never reuse or delete: $lost"-[ "$parsed" -lt "$n" ] && echo "NOTE: $((n - parsed)) of $n headers did not parse (no opening or no closing ---):" && LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {if (NR>1 && fm) print f; f=FILENAME; sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print f; nextfile}; next} fm && /^---[[:space:]]*$/ {fm=0; nextfile} END {if (fm) print f}' {} +-[ "$suspect" -gt 0 ] || [ "$a_sus" -gt 0 ] && echo "NOTE: $suspect of $n headers (and $a_sus in archive/) look like invalid YAML (an unquoted ': ', text after a closing quote, a value opening with a backtick, @ or %, an undefined escape, a colon in an unquoted list entry) — quote or fix them (File format)"-printf 'files: %s parsed: %s suspect (awk, a floor): %s archive-suspect: %s\n' "$n" "$parsed" "$suspect" "$a_sus"-printf '%s [%s] session-start scan: files=%s parsed=%s principles=%s\n' "$(date '+%F %H:%M')" "${PWD##*/}" "$n" "$parsed" "$pr" \- >> "[ABSOLUTE PATH]/skill-observations/checkpoints.log" # date+time+source: one line per session, not per day-find "$(dirname "[ABSOLUTE PATH]")" -maxdepth 3 -type d -path '*/skill-observations/observation-log' 2>/dev/null | LC_ALL=C sort | while IFS= read -r o; do printf '%s=%s\n' "${o%/skill-observations/observation-log}" "$(find "$o" -maxdepth 1 -name '[0-9]*.md' | wc -l | tr -d ' ')"; done | awk '{s = s " " $0} END {print "logs under the parent (report; never consolidate from here):" s}'-[ -f "$p" ] && awk "$pa"' a && /^### / {sub(/\r$/, ""); print}' "$p" # the active principles' headings: content, so it prints with the headers below-( export LC_ALL=C; [ "$n" -eq 0 ] || { cd "$d" && awk 'FNR==1 && NR>1 && fm {print "---"}- FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print "---"; nextfile}; next}- fm && /^---[[:space:]]*$/ {fm=0; print "---"; nextfile}- fm- END {if (fm) print "---"}' [0-9]*.md; } ) # LAST: content print, the only half a classifier can refuse; one awk for the whole set-```+The scan is `scripts/session-start-scan.sh`, the one copy: SKILL.md's+Session Start Protocol (step 2) runs it, and a reader reviews it there.+The notes below explain its parts.**Why the line carries a time and a source, not just a date.** Theworkspace is deliberately shared across every project that observes the@@ -450,7 +419,7 @@ the file count comes from a literal path, not from the variable the parseloop uses, and the assertion compares two numbers derived by differentmeans. Empty output has to earn the status of evidence.-Three properties of the snippet's form are load-bearing, and each was+Three properties of the scan's form are load-bearing, and each waslearned from a report. The guard's `parsed` count is derived by its owncommand, never by a counter incremented inside the printing loop: acounter that rides the output stream lives in a subshell the moment the@@ -505,11 +474,11 @@ Retrieval has to happen where the decision is made.**An empty scan in a log known to be non-empty is a broken command untilproven otherwise**, never the finding "no relevant observations". The-snippet's guard is what settles which of the two it is, and both halves of+scan's guard is what settles which of the two it is, and both halves ofits independence are load-bearing: the file count comes from a literalpath rather than from the variable the parse loop uses, and the assertioncompares two numbers derived by different means — halt if files exist and-nothing parsed. Keep that independence when adapting the snippet, and keep+nothing parsed. Keep that independence when adapting the scan, and keepevery path re-derived inside the same tool call. The reasoning and thereports each rule came from are in "Guard the read, not just the write"and "Snippets spanning several tool calls must re-derive their own paths"@@ -702,7 +671,7 @@ two apart from outside.### A refused print is not an empty log-The session-start scan does two different jobs in one block, and they have+The session-start scan does two different jobs in one script, and they havedifferent appetites. Everything up to and including the `checkpoints.log`write asks only for *facts about* the files: how many exist, how many have aparseable header, how many — in the directory and in `archive/` — look@@ -726,7 +695,7 @@ This is why the counts and the trace run first. Three consequences:name the reason the classifier gave, and give the counts.- **The counts-only form is the documented fallback**, not a degradedimprovisation. It still satisfies the `SCAN COMMAND BROKEN` guard, because- `n` and `parsed` both come from the half that ran. Ordering the block the+ `n` and `parsed` both come from the half that ran. Ordering the script theother way round would put the guard's own inputs downstream of the halfthat can be refused — the guard would go quiet exactly when it is needed.- **Awareness is genuinely reduced, and that is worth one line to the user.**@@ -770,7 +739,10 @@ with no ids extracted is a broken read, not an empty log — and theran, so a later reader can tell a degraded run from a skipped one. For awrite, the flat form already exists: `scripts/new-observation.sh`,invoked by absolute path, is one command with no shell operators, and it-is the only write path wherever it can run. Every mandatory step that+is the only write path wherever it can run. The scan has the same flat+form, `scripts/session-start-scan.sh` invoked by absolute path, so it is+the ladder's first rung; the flat reads follow it, for when it is refused+too or cannot run. Every mandatory step thatships a command owns a sentence saying what remains mandatory when thecommand is unavailable; this is that sentence for the scan.@@ -778,16 +750,17 @@ The ladder, one command per call, each with no shell operator a shapeclassifier could decline:```bash+bash "<skill directory>/scripts/session-start-scan.sh" "[ABSOLUTE PATH]"find "[ABSOLUTE PATH]/skill-observations/observation-log" -maxdepth 1 -name '*.md' -exec grep -H -E '^(id|title|status|skill|proposes_skill|siblings_checked):' {} +ls "[ABSOLUTE PATH]/skill-observations/observation-log"ls "[ABSOLUTE PATH]/skill-observations/observation-log/archive"cat "[ABSOLUTE PATH]/skill-observations/observation-log/archive/.id-floor"```-Combine by hand: `files` is the number of `.md` names in the first-listing, `parsed` the number of distinct files the `grep` printed an-`id:` line for, and the id maximum the largest prefix across both-listings and the floor. Then write the `checkpoints.log` line, and say+From the flat reads, combine by hand: `files` is the number of `.md`+names in the first listing, `parsed` the number of distinct files the+`grep` printed an `id:` line for, and the id maximum the largest prefix+across both listings and the floor. Then write the `checkpoints.log` line, and say"degraded form" in the session. If `-exec … +` is itself refused as acompound, the fallback is`grep -H -E '…' "[ABSOLUTE PATH]/skill-observations/observation-log"/*.md`@@ -1250,8 +1223,8 @@ top=$(for p in "$d"/[0-9]*.md; do [ -e "$p" ] && printf '%s\n' "${p##*/}"; done[ -n "${floor:-}" ] && [ -n "${top:-}" ] && [ "$((10#$floor))" -lt "$((10#$top))" ] && echo "NOTE: .id-floor ($floor) below highest active id ($top) — an issuer skipped the floor write"```-The line is optional in the core's scan snippet (the core is at its-ceiling); `scripts/new-observation.sh` runs the same check on every write+`scripts/session-start-scan.sh` does not run it (the line is optional+there); `scripts/new-observation.sh` runs the same check on every writeand corrects the floor as its own floor write. A NOTE here is evidence thatsome writer bypassed the snippet — log that as the observation, not thenumber.diff --git a/references/signals.md b/references/signals.mdindex 2d1d641..4340f80 100644--- a/references/signals.md+++ b/references/signals.md@@ -139,8 +139,9 @@ record, both run through it. Passing synthetic payloads are evidence aboutthe author's model of the input, not about the input, and the proof of theother triggers in the same file says nothing about the added one. For abarrier on shell commands, this skill's own snippets are legitimate-commands it will meet early — the id derivation and the session-start-scan are compound scripts with command substitution — so include them.+commands it will meet early — the id derivation is a compound script with+command substitution, the session-start scan a bundled script's+invocation — so include them.**Where this matters most** is the class where the absence of an error isnot evidence of success — silent corruption, a command that exits 0 havingdiff --git a/scripts/session-start-scan.sh b/scripts/session-start-scan.shnew file mode 100755index 0000000..090aa2d--- /dev/null+++ b/scripts/session-start-scan.sh@@ -0,0 +1,153 @@+#!/usr/bin/env bash+# session-start-scan.sh — the Session Start step 2 scan of the observation+# log, as one command.+#+# Usage:+# bash scripts/session-start-scan.sh [workspace-root]+#+# [workspace-root] the pinned absolute workspace path — the directory that+# holds skill-observations/. Defaults to the environment+# variable TASK_OBSERVER_WORKSPACE. One of the two is+# required; the log is never resolved from the cwd. The+# path may contain spaces.+#+# Prints, on stdout, in this order: any NOTE / LOST ENTRIES lines; the counts+# line (files, parsed, suspect, archive-suspect); the logs found under the+# root's parent; the active principles' headings; and LAST the frontmatter+# of every numbered entry, each header followed by one `---` line. Appends+# one line to skill-observations/checkpoints.log:+# YYYY-MM-DD HH:MM [<cwd's last segment>] session-start scan: files=N parsed=N principles=N+#+# Exit status:+# 0 the scan ran (NOTE lines are findings, not failures)+# 1 SCAN COMMAND BROKEN — numbered files exist but no header parsed; the+# scan halts there, before the checkpoint line and the content print+# 2 refused: no workspace root, or a root that is not an absolute path+# any other non-zero status is the content print's own (the counts and the+# checkpoint line above it already ran) — a refused or failed print is+# never an empty log+#+# This is the inline scan SKILL.md carried in step 2, unchanged in what it+# runs and prints, moved into a file for two reasons. A reader can review it+# here, line by line, instead of as one block of awk regexes inside a numbered+# step. And it no longer travels through the agent's Bash tool as text: on a+# host whose tool halves runs of backslashes (Git for Windows' bash fed one+# `-c` argument), the suspect program's `\\` runs arrived altered, the program+# stopped compiling, and `suspect` read 0 with an error on stderr. A file+# read by bash arrives exact; the one-line invocation carries no backslash.+#+# bash, not sh: the invocation names bash, and every snippet in this skill is+# bash. Runs on bash 3.2 (stock macOS): case patterns are parenthesised.++set -u++root="${1:-${TASK_OBSERVER_WORKSPACE:-}}"++if [ -z "$root" ]; then+ echo "no workspace root: pass it as the first argument or set TASK_OBSERVER_WORKSPACE" >&2; exit 2+fi+# A Windows drive path (C:/... or C:\...) is absolute there and is used as+# given: Git Bash's find, awk and dirname accept it, and the paths the scan+# prints keep the form the pin used.+case $root in+ (/*|[A-Za-z]:[/\\]*) ;;+ (*) echo "workspace root must be an ABSOLUTE path, never relative to the cwd: got '$root'" >&2; exit 2 ;;+esac++# Every expansion of $root, $d and $p stays double-quoted: the pinned path+# routinely contains a space.+d="$root/skill-observations/observation-log"++# --- counts -------------------------------------------------------------------+# n: numbered, non-empty files — what the parse can read. Counted from the+# literal path, independent of $d, so the guard below compares two numbers+# derived by different means.+n=$(find "$root/skill-observations/observation-log" -maxdepth 1 -name '[0-9]*.md' ! -empty | wc -l | tr -d ' ')+# parsed: files whose header opens on line 1 (after a UTF-8 BOM, if any) and+# closes with a second `---`. Counted by its own command, never inside the+# printing loop.+parsed=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) nextfile; next} fm && /^---[[:space:]]*$/ {print FILENAME; nextfile}' {} + | wc -l | tr -d ' ')++# --- suspect: headers that look like invalid YAML by shape (a floor) ----------+# The awk program `sus` is assembled from the named parts below, then run+# once over the active directory and once over archive/. One rule per line+# of the program, each printing the file name at its first hit:+# 1. line 1 opens the header (state resets per file, so an unclosed header+# cannot leak into the next file under find -exec … +)+# 2. the closing `---` ends the header+# 3. a plain (unquoted) value holding `: `+# 4. text after a closing quote, double- or single-quoted+# 5. a value opening with a backtick, @ or %+# 6. a double-quoted value holding an escape YAML does not define+# 7. a [ … ] list whose unquoted part holds a colon+# Every rule allows any number of spaces after the key's colon and any+# &anchor / !tag before the value. The program holds no literal brace pair:+# find -exec … {} + would replace it.+key='^[a-z_]+:[ ]+([&!][^[:space:]]*[[:space:]]+)*' # a key, its spaces, any &anchor or !tag+hx='[[:xdigit:]]' # one hex digit+# cut_short N: N hex digits cut short — k hex digits (k < N), then a non-hex+# character, as one alternation: cut_short 2 is `[^h]|h[^h]`, h being $hx.+cut_short() {+ local k i pre alt=+ for ((k = 0; k < $1; k++)); do+ pre=+ for ((i = 0; i < k; i++)); do pre="$pre$hx"; done+ alt="$alt${alt:+|}$pre[^[:xdigit:]]"+ done+ printf '%s' "$alt"+}+# The escapes a double-quoted YAML scalar defines: one character from the set,+# or \x, \u, \U followed by exactly 2, 4 and 8 hex digits.+esc_ok='\\[0abtnvfre \t\r"\/\\N_LP]|\\x'"$hx$hx"'|\\u'"$hx$hx$hx$hx"'|\\U'"$hx$hx$hx$hx$hx$hx$hx$hx"+# What follows a backslash in an undefined escape: a character outside the+# set, or \x, \u, \U with too few hex digits.+esc_bad='[^0abtnvfre \t\r"\/\\N_LPxuU]|x('"$(cut_short 2)"')|u('"$(cut_short 4)"')|U('"$(cut_short 8)"')'+sus='FNR==1 {sub(/^\357\273\277/, ""); fm = (/^---[[:space:]]*$/ ? 1 : 0); if (!fm) nextfile; next}+ fm && /^---[[:space:]]*$/ {fm=0; nextfile}+ fm && /'"$key"'[^"\047[{|>#&![:space:]].*: / {print FILENAME; nextfile}+ fm && /'"$key"'("([^"\\]|\\.)*"[[:space:]]*[^[:space:]#]|\047([^\047]|\047\047)*\047([[:space:]]+[^[:space:]#]|[^[:space:]#\047]))/ {print FILENAME; nextfile}+ fm && /'"$key"'[`@%]/ {print FILENAME; nextfile}+ fm && /'"$key"'"([^"\\]|('"$esc_ok"'))*\\('"$esc_bad"')/ {print FILENAME; nextfile}+ fm && /^[a-z_]+:[ ]+\[/ {v=$0; sub(/^[a-z_]+:[ ]+/,"",v); gsub(/"([^"\\]|\\.)*"/,"",v); gsub(/\047[^\047]*\047/,"",v); sub(/[[:space:]]#.*/,"",v); if (v ~ /:/) {print FILENAME; nextfile}}'+suspect=$(LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ')+a_sus=0; [ -d "$d/archive" ] && a_sus=$(LC_ALL=C find "$d/archive" -maxdepth 1 -name '*.md' -exec awk "$sus" {} + | wc -l | tr -d ' ') # archive/ may not exist yet++# --- principles: count the headings under `## Active Principles` --------------+# A fenced block is skipped, so a template inside the file is not a principle.+p="$root/skill-observations/cross-cutting-principles.md"+pa='/^(\140\140\140|~~~)/ {f=!f} f {next} /^## Active Principles/ {a=1; h=1; next} a && /^## / {a=0}'+pr=absent; [ -f "$p" ] && pr=$(awk "$pa"' a && /^### / {n++} END {print (h ? n+0 : "unparsed")}' "$p")+[ "$pr" = unparsed ] && echo "NOTE: the principles file has no '## Active Principles' heading — 'could not parse', not 'no principles'; read it directly"++# --- the guard: files present and nothing parsed is a broken command ----------+if [ "$n" -gt 0 ] && [ "$parsed" -eq 0 ]; then echo "SCAN COMMAND BROKEN — $n files present, 0 headers parsed"; exit 1; fi++# --- findings ----------------------------------------------------------------+# Lost entries: a zero-byte numbered file, or one with no opening `---`.+lost=$( { find "$d" -maxdepth 1 -name '[0-9]*.md' -empty; LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' ! -empty -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); if (!/^---[[:space:]]*$/) print FILENAME; nextfile}' {} +; } | sed 's|.*/||' | LC_ALL=C sort | tr '\n' ' ')+[ -n "$lost" ] && echo "LOST ENTRIES — no header, an interrupted write; report each, never reuse or delete: $lost"+# Headers that did not parse, by name: no opening, or no closing `---`.+[ "$parsed" -lt "$n" ] && echo "NOTE: $((n - parsed)) of $n headers did not parse (no opening or no closing ---):" && LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {if (NR>1 && fm) print f; f=FILENAME; sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print f; nextfile}; next} fm && /^---[[:space:]]*$/ {fm=0; nextfile} END {if (fm) print f}' {} ++[ "$suspect" -gt 0 ] || [ "$a_sus" -gt 0 ] && echo "NOTE: $suspect of $n headers (and $a_sus in archive/) look like invalid YAML (an unquoted ': ', text after a closing quote, a value opening with a backtick, @ or %, an undefined escape, a colon in an unquoted list entry) — quote or fix them (File format)"+printf 'files: %s parsed: %s suspect (awk, a floor): %s archive-suspect: %s\n' "$n" "$parsed" "$suspect" "$a_sus"++# --- the trace: one line per session, with date, time and source -------------+printf '%s [%s] session-start scan: files=%s parsed=%s principles=%s\n' "$(date '+%F %H:%M')" "${PWD##*/}" "$n" "$parsed" "$pr" \+ >> "$root/skill-observations/checkpoints.log"++# --- sibling logs: every observation log up to three levels under the parent -+# A report, never a reason to consolidate from here.+find "$(dirname "$root")" -maxdepth 3 -type d -path '*/skill-observations/observation-log' 2>/dev/null | LC_ALL=C sort | while IFS= read -r o; do printf '%s=%s\n' "${o%/skill-observations/observation-log}" "$(find "$o" -maxdepth 1 -name '[0-9]*.md' | wc -l | tr -d ' ')"; done | awk '{s = s " " $0} END {print "logs under the parent (report; never consolidate from here):" s}'++# --- content: printed with the headers below ---------------------------------+# The active principles' headings.+[ -f "$p" ] && awk "$pa"' a && /^### / {sub(/\r$/, ""); print}' "$p"+# LAST: the frontmatter of every numbered entry, one awk for the whole set+# over the directory's own glob (no word splitting of a spaced path). This is+# the only half a content classifier can refuse, so everything above has+# already run when it is.+( export LC_ALL=C; [ "$n" -eq 0 ] || { cd "$d" && awk 'FNR==1 && NR>1 && fm {print "---"}+ FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print "---"; nextfile}; next}+ fm && /^---[[:space:]]*$/ {fm=0; print "---"; nextfile}+ fm+ END {if (fm) print "---"}' [0-9]*.md; } )diff --git a/scripts/validate-skill-bundle.py b/scripts/validate-skill-bundle.pyindex 471a6b7..fd18bf3 100644--- a/scripts/validate-skill-bundle.py+++ b/scripts/validate-skill-bundle.py@@ -11,7 +11,7 @@ Usage-----python3 validate-skill-bundle.py <staged-skill-dir> [--bundle file.skill] [--pack out.skill]python3 validate-skill-bundle.py --repo-only <repo-dir>- python3 validate-skill-bundle.py --selftest # residue-check fixtures; exit 1 on any mismatch+ python3 validate-skill-bundle.py --selftest # check fixtures and the scan script; exit 1 on any mismatch--pack writes a well-formed bundle (POSIX separators on any platform)after the directory checks pass, then validates it. An@@ -654,6 +654,44 @@ ROUNDTRIP_FIXTURES = []+# The session-start scan ships as scripts/session-start-scan.sh beside this+# file. Each case runs it against a throwaway workspace (with a space in its+# path) and pins one boundary: (name, scenario, args, exit status, stdout+# substring, checkpoint lines written). Skipped, not failed, where no bash is+# on PATH: the scan is a bash script and the gate is not.+SCAN_SCRIPT = pathlib.Path(__file__).resolve().parent / "session-start-scan.sh"+SCAN_FIXTURES = [+ ("healthy log scans: counts line, one checkpoint line", "healthy", True, 0,+ "files: 2 parsed: 2 suspect (awk, a floor): 1", 1),+ ("no header parses: guard halts before the checkpoint", "broken", True, 1,+ "SCAN COMMAND BROKEN", 0),+ ("no workspace root: refused, nothing written", "healthy", False, 2, "", 0),+]+++def scan_case(scenario, pass_root):+ """Run the scan script over a fixture workspace; return (status, stdout,+ checkpoint lines written)."""+ import os+ import subprocess+ with tempfile.TemporaryDirectory() as tmp:+ root = pathlib.Path(tmp) / "work space"+ log = root / "skill-observations" / "observation-log"+ (log / "archive").mkdir(parents=True)+ ck = root / "skill-observations" / "checkpoints.log"+ ck.write_text("", encoding="utf-8")+ if scenario == "healthy":+ (log / "0001-a.md").write_text('---\nid: 1\ntitle: "ok"\n---\nbody\n', encoding="utf-8")+ (log / "0002-b.md").write_text("---\nid: 2\ntitle: Fix: unquoted\n---\n", encoding="utf-8")+ else:+ (log / "0001-a.md").write_text('---\nid: 1\ntitle: "never closed"\n', encoding="utf-8")+ env = {k: v for k, v in os.environ.items() if k != "TASK_OBSERVER_WORKSPACE"}+ args = ["bash", str(SCAN_SCRIPT)] + ([str(root)] if pass_root else [])+ r = subprocess.run(args, cwd=tmp, env=env, capture_output=True, text=True,+ encoding="utf-8", errors="replace")+ return r.returncode, r.stdout, len(ck.read_text(encoding="utf-8").splitlines())++def selftest():bad = total = 0for name, text, must_fail in RESIDUE_FIXTURES:@@ -677,6 +715,23 @@ def selftest():ok = roundtrip_case(after_pack) == must_failbad += not ok; total += 1print(f"{'ok ' if ok else 'FAIL'} round-trip: {name}")+ import shutil+ import subprocess+ if not shutil.which("bash"):+ print("skip scan script: no bash on PATH")+ elif not SCAN_SCRIPT.is_file():+ bad += 1; total += 1+ print(f"FAIL scan script: {SCAN_SCRIPT.name} missing beside this file")+ else:+ ok = subprocess.run(["bash", "-n", str(SCAN_SCRIPT)]).returncode == 0+ bad += not ok; total += 1+ print(f"{'ok ' if ok else 'FAIL'} scan script: bash -n passes")+ for name, scenario, pass_root, want_rc, want_out, want_ck in SCAN_FIXTURES:+ rc, out, ck = scan_case(scenario, pass_root)+ 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'} scan script: {name}"+ + ("" if ok else f" (exit {rc}, {ck} checkpoint lines)"))print(f"selftest: {total - bad}/{total} passed")return 1 if bad else 0