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
Refuse to overwrite an existing observation file on id collision
Eoghan Hennfc2aa2258728
diff --git a/SKILL.md b/SKILL.mdindex a30937f..1e631ed 100644--- a/SKILL.md+++ b/SKILL.md@@ -359,8 +359,7 @@ id, not a separate duty (see Archival on Write):```bashd=skill-observations/observation-logtoday=$(date +%F) # archival rides inside this command (see below):-for f in "$d"/*.md; do # stale resolved files move before the id is read- [ -e "$f" ] || continue+for f in $(find "$d" -maxdepth 1 -name '*.md'); do # stale resolved files move before the id is readhdr=$(awk 'NR==1 && /^---[[:space:]]*$/ {fm=1; next}fm && /^---[[:space:]]*$/ {exit} fm' "$f")case $hdr in@@ -375,8 +374,11 @@ for f in "$d"/*.md; do # stale resolved files move before the id is readdonehi=$( { ls "$d" "$d/archive" 2>/dev/null | grep -oE '^[0-9]+'; cat "$d/archive/.id-floor" 2>/dev/null; } \| sed 's/^0*\([0-9]\)/\1/' | sort -n | tail -1); : "${hi:=0}"-[ "$hi" -eq 0 ] && [ -n "$(ls "$d"/*.md 2>/dev/null)" ] && { echo "ID COMMAND BROKEN — log is non-empty but no ids extracted"; exit 1; }+[ "$hi" -eq 0 ] && [ -n "$(find "$d" -maxdepth 1 -name '*.md')" ] && { echo "ID COMMAND BROKEN — log is non-empty but no ids extracted"; exit 1; }next_id=$(( hi + 1 )); echo "$next_id" > "$d/archive/.id-floor"+f="$d/$(printf '%04d' "$next_id")-<slug>.md" # the target path, built from the id just derived+[ -e "$f" ] && { echo "COLLISION — $f exists; re-derive the id"; exit 1; }+(set -C; : > "$f") || exit 1 # noclobber: create, never truncate an existing file```The `sed` strips the filename prefixes' zero-padding before the@@ -387,9 +389,15 @@ prefix containing an 8 or 9 errors out.The guard line distinguishes "the log says zero" from "I could not readthe log": a command that fails to empty rather than to error wouldotherwise propose id 1 in a populated log. A new file never touches another entry's bytes, so it cannot truncate,-overwrite or renumber anyone else's work. If two parallel sessions pick the-same id, two files share a number — harmless; the next review renumbers one-and logs a meta-observation.+overwrite or renumber anyone else's work — provided it is a new file. If+two parallel sessions pick the same id and different slugs, two files+share a number — harmless; the next review renumbers one and logs a+meta-observation. If they pick the same id and the same slug (two+sessions logging the same finding at the same moment), the path is+identical and the second writer would silently replace the first, which is+why the snippet refuses an existing path and creates the file under+`noclobber` — write the body only after that create succeeds, and on a+collision re-derive the id rather than overwrite.**Run the snippet immediately before EVERY write, including the first andonly one of a session.** Having already read the log directory earlier fordiff --git a/references/observation-log.md b/references/observation-log.mdindex 3555a7d..7b375a5 100644--- a/references/observation-log.md+++ b/references/observation-log.md@@ -208,8 +208,7 @@ of a step no write can skip.```bashd=skill-observations/observation-logtoday=$(date +%F) # archival rides inside this command (see below):-for f in "$d"/*.md; do # stale resolved files move before the id is read- [ -e "$f" ] || continue+for f in $(find "$d" -maxdepth 1 -name '*.md'); do # stale resolved files move before the id is readhdr=$(awk 'NR==1 && /^---[[:space:]]*$/ {fm=1; next}fm && /^---[[:space:]]*$/ {exit} fm' "$f")case $hdr in@@ -224,8 +223,11 @@ for f in "$d"/*.md; do # stale resolved files move before the id is readdonehi=$( { ls "$d" "$d/archive" 2>/dev/null | grep -oE '^[0-9]+'; cat "$d/archive/.id-floor" 2>/dev/null; } \| sed 's/^0*\([0-9]\)/\1/' | sort -n | tail -1); : "${hi:=0}"-[ "$hi" -eq 0 ] && [ -n "$(ls "$d"/*.md 2>/dev/null)" ] && { echo "ID COMMAND BROKEN — log is non-empty but no ids extracted"; exit 1; }+[ "$hi" -eq 0 ] && [ -n "$(find "$d" -maxdepth 1 -name '*.md')" ] && { echo "ID COMMAND BROKEN — log is non-empty but no ids extracted"; exit 1; }next_id=$(( hi + 1 )); echo "$next_id" > "$d/archive/.id-floor"+f="$d/$(printf '%04d' "$next_id")-<slug>.md" # the target path, built from the id just derived+[ -e "$f" ] && { echo "COLLISION — $f exists; re-derive the id"; exit 1; }+(set -C; : > "$f") || exit 1 # noclobber: create, never truncate an existing fileprintf '%04d\n' "$next_id" # filename prefix```@@ -306,7 +308,9 @@ entries from a Status line to end-of-file, and because a parallel session'swrite-back once silently erased entries appended minutes earlier. None ofthose failure modes exist when each file is isolated. In the rare case twoparallel sessions pick the same id, the result is two files sharing a-number — harmless, distinct files, nothing lost; the next review renumbers+number — harmless, distinct files, nothing lost, as long as the slugs+differ; an identical id AND slug is one path, which is what the snippet's+existence check and `noclobber` create guard against; the next review renumbersone and logs a meta-observation.## Editing an existing observation