Skip to content

Commit 2692586

Browse files
committed
chore: sync skills + emit-schema scripts from socket-repo-template@563fd6a
Refresh: - `.claude/skills/quality-scan/SKILL.md` — junior-dev-friendly rewrite of the quality-scan skill from socket-repo-template. - `.claude/skills/updating/SKILL.md` — same, for the updating skill. - `scripts/{xport,socket-repo-template}-emit-schema.mts` — both emitters now `pnpm exec oxfmt` their output so the emitted schema matches what oxfmt produces. Without this, every fleet repo that re-emits would flag the schema as drifted on `pnpm run check --all`. - `xport.schema.json` + `socket-repo-template-schema.json` — re- emitted with the formatter applied. All synced byte-identical from socket-repo-template via sync-scaffolding.
1 parent 329e7da commit 2692586

6 files changed

Lines changed: 356 additions & 202 deletions

File tree

Lines changed: 78 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,84 @@
11
---
22
name: quality-scan
3-
description: Runs comprehensive quality scans across the codebase using specialized agents to identify critical bugs, logic errors, caching issues, and workflow problems. Use when improving code quality, before releases, or investigating issues.
3+
description: Scans the codebase for bugs, logic errors, caching issues, and workflow problems using specialized agents. Use when preparing for release, investigating quality issues, or running pre-merge checks.
4+
user-invocable: true
5+
allowed-tools: Task, Read, Grep, Glob, AskUserQuestion, Bash(pnpm run check:*), Bash(pnpm run test:*), Bash(pnpm test:*), Bash(git status:*), Bash(git diff:*), Bash(git log:*), Bash(rg:*), Bash(grep:*), Bash(find:*), Bash(ls:*)
46
---
57

68
# quality-scan
79

8-
<task>
9-
Performs comprehensive quality scans across the codebase, cleaning up junk files
10-
and spawning specialized agents for targeted analysis. Generates a prioritized
11-
report with actionable improvement tasks.
12-
</task>
13-
14-
<constraints>
15-
- Analysis phase is read-only; do not fix issues during scan.
16-
- Must complete all enabled scans before reporting.
17-
- Findings prioritized by severity (Critical > High > Medium > Low).
18-
- All findings must include file:line references and suggested fixes.
19-
- Run `pnpm test` after each fix iteration.
20-
- Cap at 5 iterations; stop and report if issues persist.
21-
</constraints>
22-
23-
## Phases
24-
25-
1. **Validate Environment**`git status`; follow `_shared/env-check.md`.
26-
2. **Update Dependencies**`pnpm run update`; continue even if it fails.
27-
3. **Install External Tools** — See `_shared/security-tools.md` for zizmor; use `pnpm run setup`.
28-
4. **Repository Cleanup** — Glob for junk files (SCREAMING_TEXT.md, temp files, editor backups); confirm before deletion.
29-
5. **Structural Validation**`pnpm run check`; report errors as Critical findings.
30-
6. **Determine Scan Scope** — Ask user: all scans, critical only, or custom selection. CI mode runs all automatically.
31-
7. **Execute Scans** — Spawn agents sequentially via Agent tool using prompts from [reference.md](reference.md). Apply `agents/code-reviewer.md` rules for code scans, `agents/security-reviewer.md` for security scans.
32-
8. **Aggregate Findings** — Deduplicate across scans, sort by severity then scan type.
33-
9. **Generate Report** — Summary table by severity + scan type, display to user.
34-
10. **Fix All Issues** — Apply fixes from Critical to Low; read each file before editing.
35-
11. **Run Tests**`pnpm test`; revert and exit iteration on failure.
36-
12. **Commit Fixes** — Stage and commit with summary of fixed issue counts.
37-
13. **Iteration Decision** — Zero issues = done; otherwise loop back to Phase 7.
38-
39-
## Available Scans
40-
41-
See [reference.md](reference.md) for detailed agent prompts. Scan types:
42-
43-
- **critical** — Crashes, security vulnerabilities, resource leaks, data corruption
44-
- **logic** — Algorithm errors, edge cases, type guards, off-by-one errors
45-
- **cache** — Cache staleness, race conditions, invalidation bugs
46-
- **workflow** — Build scripts, CI issues, cross-platform compatibility
47-
- **security** — GitHub Actions workflow security via zizmor + credential exposure
48-
- **documentation** — README accuracy, outdated docs, missing documentation
49-
50-
## Scan Scope
51-
52-
Primary: `src/`, `scripts/`, `test/`, `.github/workflows/`
53-
Excluded: `node_modules/`, `dist/`, `.pnpm-store/`
54-
55-
## Error Recovery
56-
57-
- **Scan agent failure**: Log warning, continue remaining scans.
58-
- **Test failure after fixes**: `git restore .`, report failures, exit iteration.
59-
- **Git commit failure**: Display error, ask user to resolve.
10+
Perform comprehensive quality analysis across the codebase using specialized agents. Clean up junk files first, then scan and generate a prioritized report with actionable fixes.
11+
12+
## Scan Types
13+
14+
1. **critical** - Crashes, security vulnerabilities, resource leaks, data corruption
15+
2. **logic** - Algorithm errors, edge cases, type guards, off-by-one errors
16+
3. **cache** - Cache staleness, race conditions, invalidation bugs
17+
4. **workflow** - Build scripts, CI issues, cross-platform compatibility
18+
5. **workflow-optimization** - CI optimization (build-required conditions on cached builds)
19+
6. **security** - GitHub Actions workflow security (zizmor scanner)
20+
7. **documentation** - README accuracy, outdated docs, missing documentation
21+
8. **patch-format** - Patch file format validation
22+
23+
Agent prompts for each scan type are in `reference.md`.
24+
25+
## Process
26+
27+
### Phase 1: Validate Environment
28+
29+
```bash
30+
git status
31+
```
32+
33+
Warn about uncommitted changes but continue (scanning is read-only).
34+
35+
### Phase 2: Update Dependencies
36+
37+
```bash
38+
pnpm run update
39+
```
40+
41+
Only update the current repository. Continue even if update fails.
42+
43+
### Phase 3: Install zizmor
44+
45+
Install zizmor for GitHub Actions security scanning, respecting the soak window — pnpm-workspace.yaml `minimumReleaseAge` in minutes, default 10080 (= 7 days). Query GitHub releases, find the latest stable release older than the threshold, and install via pipx/uvx. Skip the security scan if no release meets the soak requirement.
46+
47+
### Phase 4: Repository Cleanup
48+
49+
Find and remove junk files (with user confirmation via AskUserQuestion):
50+
- SCREAMING_TEXT.md files outside `.claude/` and `docs/`
51+
- Test files in wrong locations
52+
- Temp files (`.tmp`, `.DS_Store`, `*~`, `*.swp`, `*.bak`)
53+
- Log files in root/package directories
54+
55+
### Phase 5: Structural Validation
56+
57+
```bash
58+
node scripts/check-consistency.mjs
59+
```
60+
61+
Report errors as Critical findings. Warnings are Low findings.
62+
63+
### Phase 6: Determine Scan Scope
64+
65+
Ask user which scans to run using AskUserQuestion (multiSelect). Default: all scans.
66+
67+
### Phase 7: Execute Scans
68+
69+
For each enabled scan type, spawn a Task agent with the corresponding prompt from `reference.md`. Run sequentially in priority order: critical, logic, cache, workflow, then others.
70+
71+
Each agent reports findings as:
72+
- File: path:line
73+
- Issue, Severity, Pattern, Trigger, Fix, Impact
74+
75+
### Phase 8: Aggregate and Report
76+
77+
- Deduplicate findings across scan types
78+
- Sort by severity: Critical > High > Medium > Low
79+
- Generate markdown report with file:line references, suggested fixes, and coverage metrics
80+
- Offer to save to `reports/quality-scan-YYYY-MM-DD.md`
81+
82+
### Phase 9: Summary
83+
84+
Report final metrics: dependency updates, structural validation results, cleanup stats, scan counts, and total findings by severity.

.claude/skills/updating/SKILL.md

Lines changed: 118 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
---
22
name: updating
3-
description: Updates all npm dependencies to their latest versions. Triggers when user asks to "update dependencies", "update packages", or prepare for a release.
3+
description: Umbrella update skill for a Socket fleet repo. Runs `pnpm run update` (npm), validates `xport.json` via `pnpm run xport` (if present), optionally bumps submodules, and checks workflow SHA pins. Use when asked to update dependencies, sync upstreams, or prepare for a release.
44
user-invocable: true
5-
allowed-tools: Bash(pnpm:*), Bash(npm:*), Bash(git:*), Bash(node:*), Bash(rg:*), Bash(grep:*), Bash(find:*), Bash(ls:*), Bash(cat:*), Bash(head:*), Bash(tail:*), Bash(wc:*), Bash(diff:*), Read, Grep, Glob, Edit---
5+
allowed-tools: Task, Skill, Read, Edit, Grep, Glob, Bash(pnpm run:*), Bash(pnpm test:*), Bash(pnpm install:*), Bash(git:*), Bash(claude --version)
6+
---
67

78
# updating
89

910
<task>
10-
Your task is to update all npm dependencies to their latest versions, ensuring all builds and tests pass.
11+
Update all dependencies for this repo: npm packages first, then the
12+
xport-managed version pins (if `xport.json` exists), then any other
13+
submodules tracked via `.gitmodules`, and finally verify workflow
14+
SHA pins are current. Validate with the full check/test suite before
15+
committing. The sub-skill delegation mirrors the canonical
16+
socket-registry `updating` skill; uncomment the phases that apply to
17+
this repo and delete those that don't.
1118
</task>
1219

1320
<context>
1421
**What is this?**
15-
This skill updates npm packages for security patches, bug fixes, and new features.
22+
The umbrella update skill. Runs `pnpm run update` for npm deps, then
23+
adapts to what the repo has:
1624

1725
**Update Targets:**
18-
- npm packages via `pnpm run update`
26+
- **npm packages** — via `pnpm run update` (every Socket repo has this script)
27+
- **xport-managed upstreams** — via `pnpm run xport` when `xport.json` exists
28+
(manifest-managed submodule pins + advisory drift on file-fork /
29+
feature-parity / spec-conformance / lang-parity rows)
30+
- **Other submodules** — via repo-specific `updating-*` sub-skills
31+
when `.gitmodules` has entries not claimed by xport version-pin rows
32+
- **Workflow SHA pins** — check `_local-not-for-reuse-*.yml` against
33+
`origin/main`; run the `updating-workflows` skill when stale
34+
35+
**Key files this skill consults:**
36+
- `xport.json` — if present, drives version-pin bumps and surfaces drift
37+
- `.gitmodules` — listed submodules; xport's `version-pin` rows take precedence
38+
- `.github/workflows/_local-not-for-reuse-*.yml` — SHA pin sources
39+
- `package.json``pnpm run update` script
40+
41+
Sub-skills are invoked only when applicable — this umbrella reads repo
42+
state first to discover what to run.
1943
</context>
2044

2145
<constraints>
@@ -32,7 +56,9 @@ This skill updates npm packages for security patches, bug fixes, and new feature
3256

3357
**Actions:**
3458
- Update npm packages
35-
- Create atomic commits
59+
- Apply xport-driven bumps (if `xport.json` present)
60+
- Bump remaining submodules (if any)
61+
- Create atomic commits per category
3662
- Report summary of changes
3763
</constraints>
3864

@@ -42,44 +68,18 @@ This skill updates npm packages for security patches, bug fixes, and new feature
4268

4369
### Phase 1: Validate Environment
4470

45-
<action>
46-
Check working directory is clean and detect CI mode:
47-
</action>
48-
49-
```bash
50-
# Detect CI mode
51-
if [ "$CI" = "true" ] || [ -n "$GITHUB_ACTIONS" ]; then
52-
CI_MODE=true
53-
echo "Running in CI mode - will skip build validation"
54-
else
55-
CI_MODE=false
56-
echo "Running in interactive mode - will validate builds"
57-
fi
58-
59-
# Check working directory is clean
60-
git status --porcelain
61-
```
62-
63-
<validation>
64-
- Working directory must be clean
65-
- CI_MODE detected for subsequent phases
66-
</validation>
71+
Check clean working directory, detect CI mode (`CI=true` or
72+
`GITHUB_ACTIONS`), verify submodules initialized (if any).
6773

6874
---
6975

7076
### Phase 2: Update npm Packages
7177

72-
<action>
73-
Run pnpm run update to update npm dependencies:
74-
</action>
75-
7678
```bash
77-
# Update npm packages
7879
pnpm run update
7980

80-
# Check if there are changes
81-
if [ -n "$(git status --porcelain pnpm-lock.yaml package.json)" ]; then
82-
git add pnpm-lock.yaml package.json
81+
if [ -n "$(git status --porcelain)" ]; then
82+
git add pnpm-lock.yaml package.json */package.json
8383
git commit -m "chore: update npm dependencies
8484
8585
Updated npm packages via pnpm run update."
@@ -91,47 +91,104 @@ fi
9191

9292
---
9393

94-
### Phase 3: Final Validation
94+
### Phase 3: Validate xport manifest (if applicable)
9595

96-
<action>
97-
Run build and test suite (skip in CI mode):
98-
</action>
96+
If `xport.json` exists at repo root, run the harness:
9997

10098
```bash
101-
if [ "$CI_MODE" = "true" ]; then
102-
echo "CI mode: Skipping final validation (CI will run builds/tests separately)"
103-
echo "Commits created - ready for push by CI workflow"
99+
if [ -f xport.json ]; then
100+
pnpm run xport
101+
XPORT_EXIT=$?
102+
103+
case $XPORT_EXIT in
104+
0) echo "✓ xport clean — manifest valid, no drift" ;;
105+
1) echo "✗ xport schema/structural error — stopping"; exit 1 ;;
106+
2) echo "⚠ xport drift — review advisories; not a blocker" ;;
107+
esac
108+
fi
109+
```
110+
111+
Exit code semantics:
112+
- **0** — manifest valid, no drift; proceed.
113+
- **1** — schema violation, missing file, or unreachable baseline. Stop
114+
and investigate via `scripts/xport-schema.mts` and the failing row's
115+
`local_*`/`upstream` fields. Do not auto-retry.
116+
- **2** — drift detected. This is an **advisory signal** (upstream
117+
advanced, feature-parity score below floor, rejected anti-pattern
118+
reintroduced). Review the harness output, file follow-up tasks, and
119+
proceed with the update.
120+
121+
If `xport.json` does NOT exist, skip this phase.
122+
123+
---
124+
125+
### Phase 4: Update Upstream Submodules (if applicable)
126+
127+
Invoke each `updating-*` sub-skill that this repo defines. Sub-skills
128+
handle their own submodule bumps, version detection, and commits.
129+
130+
xport-managed submodules (`version-pin` rows) are auto-bumped in
131+
Phase 3 via the harness; do NOT also run a dedicated sub-skill for
132+
them. Only run sub-skills for submodules NOT claimed by xport.
133+
134+
If no `.gitmodules` exists (or all submodules are xport-managed),
135+
skip this phase.
136+
137+
---
138+
139+
### Phase 5: Check Workflow SHA Pins
140+
141+
Inspect `_local-not-for-reuse-*.yml` files for their pinned SHA and
142+
compare against `origin/main`:
143+
144+
```bash
145+
PINNED_SHA=$(grep -ohP '(?<=@)[0-9a-f]{40}' .github/workflows/_local-not-for-reuse-ci.yml 2>/dev/null | head -1)
146+
MAIN_SHA=$(git rev-parse origin/main 2>/dev/null || echo "")
147+
148+
if [ -n "$PINNED_SHA" ] && [ -n "$MAIN_SHA" ] && [ "$PINNED_SHA" != "$MAIN_SHA" ]; then
149+
echo "Workflow SHA pins are stale: $PINNED_SHA$MAIN_SHA"
150+
echo "Run the updating-workflows skill to cascade."
151+
else
152+
echo "Workflow SHA pins are up to date (or no _local-not-for-reuse-*.yml pins in this repo)"
153+
fi
154+
```
155+
156+
---
157+
158+
### Phase 6: Final Validation (skip in CI)
159+
160+
```bash
161+
if [ "$CI" = "true" ] || [ -n "$GITHUB_ACTIONS" ]; then
162+
echo "CI mode: skipping validation"
104163
else
105-
echo "Interactive mode: Running full validation..."
106-
pnpm run fix --all
107164
pnpm run check --all
108165
pnpm test
166+
pnpm run build # if this repo has a build step
109167
fi
110168
```
111169

112170
---
113171

114-
### Phase 4: Report Summary
115-
116-
<action>
117-
Generate update report:
118-
</action>
172+
### Phase 7: Report Summary
119173

120174
```
121175
## Update Complete
122176
123177
### Updates Applied:
124178
125-
| Category | Status |
126-
|----------|--------|
127-
| npm packages | Updated/Up to date |
179+
| Category | Status |
180+
|--------------------|--------------------------------------|
181+
| npm packages | Updated / Up to date |
182+
| xport manifest | <ok>/<total> ok, <drift> drift, <error> error (exit <code>) — or n/a |
183+
| Other submodules | K bumped — or n/a |
184+
| Workflow SHA pins | Up to date / Stale |
128185
129186
### Commits Created:
130-
- [list commits if any]
187+
- [list commits, if any]
131188
132189
### Validation:
133-
- Build: SUCCESS/SKIPPED (CI mode)
134-
- Tests: PASS/SKIPPED (CI mode)
190+
- Build: SUCCESS / SKIPPED (CI mode)
191+
- Tests: PASS / SKIPPED (CI mode)
135192
136193
### Next Steps:
137194
**Interactive mode:**
@@ -149,15 +206,18 @@ Generate update report:
149206
## Success Criteria
150207

151208
- All npm packages checked for updates
209+
- xport manifest validated (when present); schema/structural errors block
152210
- Full build and tests pass (interactive mode)
153211
- Summary report generated
154212

155213
## Context
156214

157215
This skill is useful for:
158216

159-
- Weekly maintenance (automated via weekly-update.yml)
217+
- Weekly maintenance (automated via `weekly-update.yml`)
160218
- Security patch rollout
161219
- Pre-release preparation
162220

163-
**Safety:** Updates are validated before committing. Failures stop the process.
221+
**Safety:** Updates are validated before committing. Schema errors
222+
(xport exit 1) stop the process; drift (xport exit 2) is advisory
223+
and does not block.

0 commit comments

Comments
 (0)