Memory files for decisions, bash gotchas, and process lessons. Updated MEMORY.md index and README.md with new scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.4 KiB
3.4 KiB
Session Log — 2026-03-13
Summary
Created the small-scripts project — a spec-driven utility script collection with dryrun support and automated testing. Implemented the first script git-status-report which recursively scans directories for git repos and reports uncommitted changes with character-level diffs and remote sync status.
Decisions
- Decision: Use OpenSpec format for all script specifications — Rationale: Testing agent-driven development; specs define purpose, usage, behaviour, dryrun behaviour, edge cases, and examples
- Decision: Every script must support
--dryrun/-n— Rationale: Enables testing via dryrun without side effects; tests validate spec compliance through dryrun output - Decision: Removed
set -efrom git-status-report, keptset -uo pipefail— Rationale:set -ecaused silent failures in complex pipeline/subshell chains; for a reporting tool, explicit error handling is safer than errexit - Decision: "No remotes" and "detached HEAD" don't count as dirty — Rationale: These are informational states, not divergences; "(no remotes)" only shown when repo already has local changes
- Decision: Project hosted under
skynetorg on Gitea — Rationale: AI-focused project (agent-driven development testbed)
Gotchas Discovered
- [bash] Symptom:
set -euo pipefailcaused silent script termination with no output during complex loops with command substitutions and subshell calls — Fix: Removedset -e, keptset -uo pipefail. Reporting tools don't need errexit; explicit error handling is more predictable. - [bash] Symptom:
grep -qF "$expected"interpreted--dryrunas a grep flag — Fix: Usegrep -qF -- "$expected"to prevent option-like strings from being parsed as flags - [bash] Symptom:
localkeyword used outside a function in main loop body causedlocal: can only be used in a functionerror — Fix: Removelocalqualifier for variables in the main script body - [bash] Symptom:
set -ein test script killed execution when capturing output from commands expected to exit non-zero (output=$(cmd)where cmd exits 1) — Fix: Useoutput=$(cmd) && rc=$? || rc=$?oroutput=$(cmd) || truepattern - [bash] Symptom:
filecommand on shell scripts returns "executable" which matched the binary detection grepbinary\|executable\|image\|archive— Fix: Changed togrep -qP "binary|image|archive"with additional! grep -q "text"check to avoid false positives on text executables
Key Context
- Project structure:
specs/(OpenSpec),scripts/(implementations),tests/(test scripts using dryrun) - Scripts symlinked to
~/sbinfor PATH availability - Test runner at
tests/run-all.shwith colour pass/fail output - First script
git-status-reporthas 26 test assertions covering: help, no repos, dryrun, clean/dirty repos, untracked/deleted files, no remotes, ahead of remote, mixed repos, nested repo filtering, permission denied
Process Notes
- The
set -edebugging consumed significant time — the script worked in isolated tests but failed silently on real repos. Future scripts should start withoutset -efor reporting/read-only tools. - Test development caught real bugs (grep flag parsing, local keyword misuse) — the spec-driven approach with comprehensive tests works well.
- The
filecommand for binary detection is unreliable for scripts; need a better heuristic (maybegit diff --numstatwhich shows-for binary files).