The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(skill-stocktake): invalidate stale resumed evaluations
Yann Roberto9a1ccaaf25a9
diff --git a/manifests/context-packs/[email protected] b/manifests/context-packs/[email protected]index d4074a6fa..0aff6eb0e 100644--- a/manifests/context-packs/[email protected]+++ b/manifests/context-packs/[email protected]@@ -1 +1,288 @@-{"coverage":{"skills":293,"withTriggers":32},"generatedAt":"2026-09-24T23:51:22.784Z","id":"skill-triggers@1","model":{"effort":null,"id":"hand-seeded","source":"manual-curation-pending-regeneration"},"registryDigest":"6f30cf67553729dbc7be4a6f765fd3714ced362669e40a45656ea9eb40fbc0a2","schemaVersion":1,"triggers":{"skill:api-connector-builder":["add api integration","new provider connector","match existing integration pattern"],"skill:api-design":["rest endpoint design","pagination api","status codes","api versioning","rate limiting api","resource naming","filtering api","api error responses","offset pagination","limit query parameter","pagination defaults"],"skill:backend-patterns":["express api","node backend architecture","nextjs api routes","server side patterns","data access layer","static file server","url path handling","file server"],"skill:browser-qa":["deployed feature test","visual regression screenshots","core web vitals check","axe accessibility audit","ship do not ship","staging verification"],"skill:canary-watch":["post deploy monitoring","smoke test url","production url check","console errors production","sse stream check","after deploy verification"],"skill:code-tour":["onboarding walkthrough","explain subsystem","architecture tour","pr walkthrough","rca tour"],"skill:coding-standards":["code review standards","naming conventions","readability review","immutability conventions","fix naming typo","export naming","consistent exports"],"skill:content-hash-cache-pattern":["cache file processing","content addressed cache","sha256 hash cache"],"skill:database-migrations":["zero downtime migration","schema change production","add column large table","backfill data","expand contract","concurrent index","migration rollback","prisma migration","django migration"],"skill:deployment-patterns":["ci cd setup","dockerize app","health checks","rollback strategy","production readiness","deploy pipeline","containerize application"],"skill:design-system":["design tokens","visual consistency audit","css custom properties","ui audit","design system bootstrap"],"skill:django-patterns":["django orm","drf api","django rest framework","django caching","django signals","django middleware"],"skill:django-security":["django authentication","csrf protection","sql injection prevention","xss prevention","django deployment security","role based access control","authorization middleware","permissions checks"],"skill:docker-patterns":["dockerfile review","docker compose setup","container security","multi service orchestration"],"skill:error-handling":["error types","retry logic","circuit breaker","user facing errors","exception handling patterns","typed errors","error boundaries","go error handling","custom error class","error codes","config validation"],"skill:evm-token-decimals":["token decimals","wei conversion","erc20 balance off","bridge token precision"],"skill:frontend-a11y":["aria attributes","screen reader support","focus management","semantic html","form labeling","keyboard navigation react","a11y lint errors"],"skill:git-workflow":["merge vs rebase","commit conventions","resolve merge conflict","branching strategy","clean up commits","pull request cleanup","git history tidy"],"skill:hexagonal-architecture":["ports and adapters","dependency injection boundaries","decouple domain from io"],"skill:kubernetes-patterns":["kubernetes manifests","kubectl debugging","pod probes","k8s rbac","autoscaling config","configmap secrets"],"skill:orch-fix-defect":["fix a bug","broken behavior","regression fix","reproduce bug","defect repair"],"skill:postgres-patterns":["slow postgres query","query optimization","index design","rls policies","supabase schema","postgres indexing","database performance","schema design postgres","postgres driver","node postgres","query planner"],"skill:python-patterns":["pythonic code","pep 8","type hints python","python code review","idiomatic python"],"skill:python-testing":["pytest fixtures","mocking python","parametrized tests","coverage python","tdd python"],"skill:redis-patterns":["cache aside pattern","distributed lock","redis rate limiting","cache invalidation"],"skill:regex-vs-llm-structured-text":["parse invoice","extract receipt data","text extraction pipeline","parse form fields","cheap document parser","extract table data","parse log lines","parse access logs","common log format","log line parsing"],"skill:rust-patterns":["rust ownership","borrow checker","rust error handling","traits rust","rust concurrency","idiomatic rust"],"skill:search-first":["find existing library","npm package research","before writing custom code","evaluate existing tools","add dependency research"],"skill:security-review":["security audit","authentication review","sanitize user input","secrets handling","payment security checklist","prevent injection attacks","secure api endpoints","authn authz review","vulnerability checklist","input validation security","parameterized queries","sql injection"],"skill:security-scan":["audit claude config","claudemd security","mcp server audit","agentshield scan","hook configuration audit","settings json security"],"skill:tdd-workflow":["write test first","failing test","red green refactor","test driven development","regression test first","write a regression test"],"skill:verification-loop":["pre pr checks","verification report","quality gates","build lint test coverage","before creating a pr"]},"triggersDigest":"25b97a9e06fc336c7cf95ab854ed1a41033a54bcd6e1fb1cf69dc906332462aa"}+{+ "coverage": {+ "skills": 293,+ "withTriggers": 32+ },+ "generatedAt": "2026-09-24T23:51:22.784Z",+ "id": "skill-triggers@1",+ "model": {+ "effort": null,+ "id": "hand-seeded",+ "source": "manual-curation-pending-regeneration"+ },+ "registryDigest": "90e7044c69e1672ea473fa9930c7a7e210f6de2ddc6bb43e56c2032c2688ba30",+ "schemaVersion": 1,+ "triggers": {+ "skill:api-connector-builder": [+ "add api integration",+ "new provider connector",+ "match existing integration pattern"+ ],+ "skill:api-design": [+ "rest endpoint design",+ "pagination api",+ "status codes",+ "api versioning",+ "rate limiting api",+ "resource naming",+ "filtering api",+ "api error responses",+ "offset pagination",+ "limit query parameter",+ "pagination defaults"+ ],+ "skill:backend-patterns": [+ "express api",+ "node backend architecture",+ "nextjs api routes",+ "server side patterns",+ "data access layer",+ "static file server",+ "url path handling",+ "file server"+ ],+ "skill:browser-qa": [+ "deployed feature test",+ "visual regression screenshots",+ "core web vitals check",+ "axe accessibility audit",+ "ship do not ship",+ "staging verification"+ ],+ "skill:canary-watch": [+ "post deploy monitoring",+ "smoke test url",+ "production url check",+ "console errors production",+ "sse stream check",+ "after deploy verification"+ ],+ "skill:code-tour": [+ "onboarding walkthrough",+ "explain subsystem",+ "architecture tour",+ "pr walkthrough",+ "rca tour"+ ],+ "skill:coding-standards": [+ "code review standards",+ "naming conventions",+ "readability review",+ "immutability conventions",+ "fix naming typo",+ "export naming",+ "consistent exports"+ ],+ "skill:content-hash-cache-pattern": [+ "cache file processing",+ "content addressed cache",+ "sha256 hash cache"+ ],+ "skill:database-migrations": [+ "zero downtime migration",+ "schema change production",+ "add column large table",+ "backfill data",+ "expand contract",+ "concurrent index",+ "migration rollback",+ "prisma migration",+ "django migration"+ ],+ "skill:deployment-patterns": [+ "ci cd setup",+ "dockerize app",+ "health checks",+ "rollback strategy",+ "production readiness",+ "deploy pipeline",+ "containerize application"+ ],+ "skill:design-system": [+ "design tokens",+ "visual consistency audit",+ "css custom properties",+ "ui audit",+ "design system bootstrap"+ ],+ "skill:django-patterns": [+ "django orm",+ "drf api",+ "django rest framework",+ "django caching",+ "django signals",+ "django middleware"+ ],+ "skill:django-security": [+ "django authentication",+ "csrf protection",+ "sql injection prevention",+ "xss prevention",+ "django deployment security",+ "role based access control",+ "authorization middleware",+ "permissions checks"+ ],+ "skill:docker-patterns": [+ "dockerfile review",+ "docker compose setup",+ "container security",+ "multi service orchestration"+ ],+ "skill:error-handling": [+ "error types",+ "retry logic",+ "circuit breaker",+ "user facing errors",+ "exception handling patterns",+ "typed errors",+ "error boundaries",+ "go error handling",+ "custom error class",+ "error codes",+ "config validation"+ ],+ "skill:evm-token-decimals": [+ "token decimals",+ "wei conversion",+ "erc20 balance off",+ "bridge token precision"+ ],+ "skill:frontend-a11y": [+ "aria attributes",+ "screen reader support",+ "focus management",+ "semantic html",+ "form labeling",+ "keyboard navigation react",+ "a11y lint errors"+ ],+ "skill:git-workflow": [+ "merge vs rebase",+ "commit conventions",+ "resolve merge conflict",+ "branching strategy",+ "clean up commits",+ "pull request cleanup",+ "git history tidy"+ ],+ "skill:hexagonal-architecture": [+ "ports and adapters",+ "dependency injection boundaries",+ "decouple domain from io"+ ],+ "skill:kubernetes-patterns": [+ "kubernetes manifests",+ "kubectl debugging",+ "pod probes",+ "k8s rbac",+ "autoscaling config",+ "configmap secrets"+ ],+ "skill:orch-fix-defect": [+ "fix a bug",+ "broken behavior",+ "regression fix",+ "reproduce bug",+ "defect repair"+ ],+ "skill:postgres-patterns": [+ "slow postgres query",+ "query optimization",+ "index design",+ "rls policies",+ "supabase schema",+ "postgres indexing",+ "database performance",+ "schema design postgres",+ "postgres driver",+ "node postgres",+ "query planner"+ ],+ "skill:python-patterns": [+ "pythonic code",+ "pep 8",+ "type hints python",+ "python code review",+ "idiomatic python"+ ],+ "skill:python-testing": [+ "pytest fixtures",+ "mocking python",+ "parametrized tests",+ "coverage python",+ "tdd python"+ ],+ "skill:redis-patterns": [+ "cache aside pattern",+ "distributed lock",+ "redis rate limiting",+ "cache invalidation"+ ],+ "skill:regex-vs-llm-structured-text": [+ "parse invoice",+ "extract receipt data",+ "text extraction pipeline",+ "parse form fields",+ "cheap document parser",+ "extract table data",+ "parse log lines",+ "parse access logs",+ "common log format",+ "log line parsing"+ ],+ "skill:rust-patterns": [+ "rust ownership",+ "borrow checker",+ "rust error handling",+ "traits rust",+ "rust concurrency",+ "idiomatic rust"+ ],+ "skill:search-first": [+ "find existing library",+ "npm package research",+ "before writing custom code",+ "evaluate existing tools",+ "add dependency research"+ ],+ "skill:security-review": [+ "security audit",+ "authentication review",+ "sanitize user input",+ "secrets handling",+ "payment security checklist",+ "prevent injection attacks",+ "secure api endpoints",+ "authn authz review",+ "vulnerability checklist",+ "input validation security",+ "parameterized queries",+ "sql injection"+ ],+ "skill:security-scan": [+ "audit claude config",+ "claudemd security",+ "mcp server audit",+ "agentshield scan",+ "hook configuration audit",+ "settings json security"+ ],+ "skill:tdd-workflow": [+ "write test first",+ "failing test",+ "red green refactor",+ "test driven development",+ "regression test first",+ "write a regression test"+ ],+ "skill:verification-loop": [+ "pre pr checks",+ "verification report",+ "quality gates",+ "build lint test coverage",+ "before creating a pr"+ ]+ },+ "triggersDigest": "25b97a9e06fc336c7cf95ab854ed1a41033a54bcd6e1fb1cf69dc906332462aa"+}diff --git a/skills/skill-stocktake/SKILL.md b/skills/skill-stocktake/SKILL.mdindex 2451c29ea..aa4d16bfd 100644--- a/skills/skill-stocktake/SKILL.md+++ b/skills/skill-stocktake/SKILL.md@@ -81,7 +81,10 @@ Run this entire block in **one Bash invocation**. It prints the inventory for th. as $inventory | $saved[0]| .skills = (.skills | to_entries| map(.key = (.value.path // .key))- | map(select(.key as $p | any($inventory.skills[]; .path == $p)))+ | map(select(. as $entry+ | $entry.value.mtime != null+ and any($inventory.skills[];+ .path == $entry.key and .mtime == $entry.value.mtime)))| from_entries)| .mode = "full"| .batch_progress = {@@ -117,7 +120,7 @@ Scanning:Usage counts come from the optional `~/.claude/observations.jsonl` file (overridable with `SKILL_STOCKTAKE_OBSERVATIONS`), which Claude Code does not create by default. When the file is absent, `use_7d` and `use_30d` are JSON `null`; display them as **unmeasured** in inventory and summary tables. A numeric `0` means the file exists but contains no matching Read observations in that window. Missing usage data is never evidence for retiring a skill.-`--replace` writes a complete cache snapshot. A new run starts with an empty evaluation; a resumed run instead keeps every saved evaluation whose path is still in the live inventory, removes archived/deleted entries, and refreshes the progress counts even when no new batch remains. Existing name-keyed entries are normalized using their saved `path`. Never use the empty initialization payload for a resume. Later chunks, completion updates, and Quick Scans must omit `--replace` so they merge into the current run instead of losing earlier results.+`--replace` writes a complete cache snapshot. A new run starts with an empty evaluation; a resumed run instead keeps a saved evaluation only when its path is still live and its saved, non-null mtime matches the fresh inventory. Changed skills and entries without an mtime require re-evaluation. It removes archived/deleted entries and refreshes the progress counts even when no new batch remains. Existing name-keyed entries are normalized using their saved `path`. Never use the empty initialization payload for a resume. Later chunks, completion updates, and Quick Scans must omit `--replace` so they merge into the current run instead of losing earlier results.### Phase 2 — Quality Evaluation@@ -150,7 +153,7 @@ After all skills are evaluated, persist completion before proceeding to Phase 3:)```-**Resume detection:** If `status: "in_progress"` is found on startup, run Phase 1 to reconcile the saved results with the fresh inventory, then evaluate only paths absent from the reconciled `skills` map. If none remain, persist completion immediately. Completed evaluations for surviving paths are preserved; newly added paths still require evaluation.+**Resume detection:** If `status: "in_progress"` is found on startup, run Phase 1 to reconcile the saved results with the fresh inventory, then evaluate only paths absent from the reconciled `skills` map. If none remain, persist completion immediately. Completed evaluations are preserved only for surviving paths with matching, non-null mtimes; new or changed skills and entries without an mtime require evaluation.Each skill is evaluated against this checklist:diff --git a/tests/scripts/skill-stocktake-discovery.test.js b/tests/scripts/skill-stocktake-discovery.test.jsindex f82548bc6..5bfcdbc3d 100644--- a/tests/scripts/skill-stocktake-discovery.test.js+++ b/tests/scripts/skill-stocktake-discovery.test.js@@ -277,6 +277,66 @@ if (process.platform !== 'win32') {}}++if (process.platform !== 'win32') {+ const skillSource = fs.readFileSync(path.join(repoRoot, 'skills', 'skill-stocktake', 'SKILL.md'), 'utf8');+ const inventorySection = skillSource.split('### Phase 1')[1].split('### Phase 2')[0];+ const inventoryBlock = inventorySection.match(/```bash\n([\s\S]*?)\n```/)[1];+ for (const scenario of ['changed', 'missing mtime', 'null mtime', 'matching', 'legacy matching']) {+ test('documented resume reevaluates stale skills and preserves current evaluations (' + scenario + ')', () => {+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-stocktake-resume-'));+ try {+ const home = path.join(tempRoot, 'home');+ const skills = path.join(home, '.claude', 'skills');+ const stocktake = path.join(skills, 'skill-stocktake');+ fs.mkdirSync(stocktake, { recursive: true });+ fs.cpSync(path.dirname(scanScript), path.join(stocktake, 'scripts'), { recursive: true });+ const skillDir = path.join(skills, 'live');+ writeSkill(skillDir, 'live');+ const skillPath = path.join(skillDir, 'SKILL.md');+ fs.utimesSync(skillPath, new Date('2025-01-01T00:00:00Z'), new Date('2025-01-01T00:00:00Z'));+ const env = {+ ...process.env,+ HOME: home,+ SKILL_STOCKTAKE_GLOBAL_DIR: skills,+ SKILL_STOCKTAKE_PROJECT_DIR: path.join(tempRoot, 'missing-project'),+ SKILL_STOCKTAKE_OBSERVATIONS: path.join(tempRoot, 'missing-observations'),+ };+ const runInventory = () => spawnSync('bash', ['-c', inventoryBlock], {+ cwd: tempRoot, env, encoding: 'utf8', timeout: 30000,+ });+ const initial = runInventory();+ assert.strictEqual(initial.status, 0, initial.stderr);+ const scanned = JSON.parse(initial.stdout).skills[0];+ const entry = {+ path: scanned.path, verdict: 'Keep', reason: 'Preserve the reviewed content',+ ...(scenario === 'missing mtime' ? {} : { mtime: scenario === 'null mtime' ? null : scanned.mtime }),+ };+ const resultsPath = path.join(stocktake, 'results.json');+ fs.writeFileSync(resultsPath, JSON.stringify({+ mode: 'full',+ skills: { [scenario === 'legacy matching' ? 'live' : scanned.path]: entry },+ batch_progress: { total: 1, evaluated: 1, status: 'in_progress' },+ }));+ if (scenario === 'changed') {+ fs.appendFileSync(skillPath, '\nContent changed after its evaluation.\n');+ fs.utimesSync(skillPath, new Date('2025-01-02T00:00:00Z'), new Date('2025-01-02T00:00:00Z'));+ }+ const resumed = runInventory();+ assert.strictEqual(resumed.status, 0, resumed.stderr);+ const output = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));+ const preserved = scenario === 'matching' || scenario === 'legacy matching';+ assert.deepStrictEqual(output.skills, preserved ? { [scanned.path]: entry } : {});+ assert.deepStrictEqual(output.batch_progress, {+ total: 1, evaluated: preserved ? 1 : 0, status: 'in_progress',+ });+ } finally {+ fs.rmSync(tempRoot, { recursive: true, force: true });+ }+ });+ }+}+console.log(`\nPassed: ${passed}`);console.log(`Failed: ${failed}`);process.exit(failed > 0 ? 1 : 0);