From 3ce25a03a0d32dae4ef4ca4759bcfaaad6dd3ab0 Mon Sep 17 00:00:00 2001 From: Gale W Date: Mon, 22 Jun 2026 13:28:51 -0400 Subject: [PATCH 1/2] docs: add token efficiency audit report --- ...-efficiency-automation-audit-2026-06-22.md | 390 ++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100644 docs/agents/token-efficiency-automation-audit-2026-06-22.md diff --git a/docs/agents/token-efficiency-automation-audit-2026-06-22.md b/docs/agents/token-efficiency-automation-audit-2026-06-22.md new file mode 100644 index 00000000..dae9f2fa --- /dev/null +++ b/docs/agents/token-efficiency-automation-audit-2026-06-22.md @@ -0,0 +1,390 @@ +# Token Efficiency and Automation Audit + +Date: 2026-06-22 +Branch: `audit/token-efficiency-automation` + +## Summary + +Socket has several good existing boundaries for reducing hand-carried work: +shared Apple snippet sources, maintainer automation guidance, source-bundled +steward roles, root marketplace validation, and child validation in some +plugins. The largest remaining token-efficiency opportunities are not generic +style edits. They are moving repeated high-churn facts into narrower references, +making generated or mirrored guidance less expensive to load, and adding +automation that inventories drift before humans edit skill prose. + +Top priorities: + +1. Collapse repeated SwiftASB API inventory into one current-state reference and + keep per-skill files focused on routing, ownership, and workflow-specific + decisions. +2. Replace repeated productivity-skill subagent prose with a short local fit + paragraph plus the existing shared maintainer guidance. +3. Treat Apple shared snippets as generated mirrors and add drift/size reporting + so their duplication is visible before release. +4. Define Socket-owned F# `.fsx` conventions for typed hooks and compact local + maintenance scripts, but do not migrate Python validators or the current Node + hook until portability and startup costs are measured. +5. Add a root skill-surface audit script that reports large skills, duplicate + snippets, stale current-version wording, missing handoff references, and + repeated boilerplate. + +## Evidence Snapshot + +- `plugins/apple-dev-skills`: 21 skill files, 3,401 `SKILL.md` lines. +- `plugins/python-skills`: 12 skill files, 1,906 `SKILL.md` lines. +- `plugins/swiftasb-skills`: 6 skill files, 1,467 `SKILL.md` lines. +- `plugins/productivity-skills`: 14 skill files, 1,580 `SKILL.md` lines. +- Root skill total: 12,703 `SKILL.md` lines across shipped child plugins. +- Root reference total: 11,439 Markdown reference lines under skill references. +- `apple-dev-skills` carries 23 skill-local snippet copies in three identical + checksum groups. +- `productivity-skills` repeats the phrase `When the user explicitly requests + subagents` in 10 maintainer skills, plus one `agent-plugin-skills` workflow. +- `swiftasb-skills` repeats startup, diagnostics, feature-operation, generated + wire-model, same-thread overlap, and Apple handoff facts across multiple + skills. +- Current script inventory includes one `.mjs` file with 592 lines, 137 Python + files with 35,750 lines, 29 shell files with 4,675 lines, and no `.fsx` or + `.fs` files. +- The roadmap now includes an explicit Socket-owned F# `.fsx` hook and + maintenance-script conventions item covering launch shape, repo-local + `DOTNET_CLI_HOME`, event JSON types, validation, and graduation to compiled + F# tools. + +## Quick Wins + +### 1. Add a root token-surface audit script + +Create `scripts/audit_skill_surfaces.py` with a report-only default that emits: + +- skill line counts by plugin and skill +- reference line counts by plugin and reference +- exact duplicate reference checksums +- repeated phrase counts from a repo-owned phrase list +- version-sensitive phrases such as `As of SwiftASB v...` +- missing expected handoff references for known cross-skill boundaries + +This should not fail release validation at first. Start with advisory output so +maintainers can see hotspots without blocking unrelated plugin work. + +Evidence: + +- Root validation already validates marketplace wiring in + `scripts/validate_socket_metadata.py`. +- Apple has a manual snippet sync script at + `plugins/apple-dev-skills/.github/scripts/sync_shared_snippets.sh`. +- Python has a child metadata validator at + `plugins/python-skills/scripts/validate_repo_metadata.py`. + +### 2. Put the Apple snippet mirror check into validation + +`apple-dev-skills` already has canonical sources under +`plugins/apple-dev-skills/shared/agents-snippets/` and a script that copies them +into skill-local `references/snippets/` files. That is a good source-of-truth +shape, but the repo should also be able to detect drift without relying on a +maintainer remembering to run the sync script. + +Recommended first step: + +- Add a check mode to `sync_shared_snippets.sh`, or add a small Python validator + that compares each target with its canonical source. +- Include the check in the Apple child validation path. +- Keep copies for now if current skill-loader behavior requires references to + stay inside each skill directory. + +Evidence: + +- The sync script copies `apple-xcode-project-core.md` into 12 skills and + `apple-swift-package-core.md` into 5 skills. +- The copied snippets are large enough to matter: 104 lines for Xcode project + core and 82 lines for Swift package core. + +### 3. Replace repeated productivity subagent boilerplate with compact pointers + +`productivity-skills/docs/maintainers/codex-subagent-guidance.md` already defines +the shared model, good fits, poor fits, and wording pattern. Individual +maintenance skills only need: + +- whether this skill can use read-heavy subagents +- the skill-specific examples of useful worker jobs +- whether apply-mode edits stay in the main thread + +Avoid repeating the whole trigger model in every skill. Keep one sentence in the +skill and link the maintainer guidance for the durable policy. + +Evidence: + +- `maintain-project-readme` lines 47-51 carry a local subagent section. +- The shared maintainer guidance already covers trigger rules, model selection, + sandbox behavior, good fits, poor fits, and wording pattern. + +### 4. Add report-only stale-version detection for high-churn skills + +SwiftASB skills contain current-version claims such as `As of SwiftASB v1.6.0`. +Those claims are valuable, but they become expensive and risky when copied +across several large skills. + +Add an audit that reports: + +- all `As of ... vX.Y.Z` phrases +- all repeated symbol inventories over a threshold +- all SwiftASB skills that mention a current API symbol but do not link to a + shared reference + +Do not block validation until the plugin has a chosen shared-reference shape. + +### 5. Define an `.fsx` convention before migrating scripts + +The current repo has no `.fsx` files. The best first move is a convention note or +small proof script, not a migration. The convention should answer the roadmap +questions directly: + +- place Socket-owned F# scripts under the owning plugin's `scripts/` directory, + not under root unless the script operates on the Socket superproject +- launch hook scripts through a tiny POSIX wrapper using + `dotnet fsi --exec