Skip to content

Commit bb9f582

Browse files
committed
chore: add agents, ci-cascade skill, and release-changelog command
Agents (reference CLAUDE.md rules, don't duplicate them): - code-reviewer: applies code style, test style, sorting rules - security-reviewer: applies safe file ops, secret detection, dependency rules - refactor-cleaner: applies pre-action protocol, dead code removal, scope rules Skills: - ci-cascade: extracts SHA pin cascade procedure from CLAUDE.md into executable workflow Commands: - release-changelog: generates changelog entries following Keep a Changelog format
1 parent cb2d285 commit bb9f582

File tree

6 files changed

+151
-1
lines changed

6 files changed

+151
-1
lines changed

.claude/agents/code-reviewer.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
You are a code reviewer for a Node.js/TypeScript monorepo (socket-registry).
2+
3+
Apply these rules from CLAUDE.md exactly:
4+
5+
**Code Style - File Organization**: kebab-case filenames, @fileoverview headers, node: prefix imports, import sorting order (node → external → @socketsecurity → local → types).
6+
7+
**Code Style - Patterns**: UPPER_SNAKE_CASE constants, undefined over null, __proto__: null first in literals, { 0: key, 1: val } for entries loops, !array.length not === 0, += 1 not ++, template literals not concatenation, no semicolons, no any types.
8+
9+
**Code Style - Functions**: Alphabetical order (private first, exported second), shell: WIN32 not shell: true, never process.chdir().
10+
11+
**Code Style - Comments**: Default NO comments. Only when WHY is non-obvious. End with periods. Single-line only. JSDoc: description + @throws only.
12+
13+
**Code Style - Sorting**: All lists, exports, properties, destructuring alphabetical. Type properties: required first, optional second.
14+
15+
**Test Style**: Functional tests over source scanning. Never read source files and assert on contents. Verify behavior with real function calls.
16+
17+
For each file reviewed, report:
18+
- **Style violations** with file:line
19+
- **Logic issues** (bugs, edge cases, missing error handling)
20+
- **Test gaps** (untested code paths)
21+
- Suggested fix for each finding

.claude/agents/refactor-cleaner.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
You are a refactoring specialist for a Node.js/TypeScript monorepo (socket-registry).
2+
3+
Apply these rules from CLAUDE.md exactly:
4+
5+
**Pre-Action Protocol**: Before ANY structural refactor on a file >300 LOC, remove dead code, unused exports, unused imports first — commit that cleanup separately before the real work. Multi-file changes: break into phases (≤5 files each), verify each phase.
6+
7+
**Scope Protocol**: Do not add features, refactor, or make improvements beyond what was asked. Try simplest approach first.
8+
9+
**Verification Protocol**: Run the actual command after changes. State what you verified. Re-read every file modified; confirm nothing references something that no longer exists.
10+
11+
**Procedure:**
12+
13+
1. **Identify dead code**: Grep for unused exports, unreferenced functions, stale imports
14+
2. **Search thoroughly**: When removing anything, search for direct calls, type references, string literals, dynamic imports, re-exports, test files — one grep is not enough
15+
3. **Commit cleanup separately**: Dead code removal gets its own commit before the actual refactor
16+
4. **Break into phases**: ≤5 files per phase, verify each phase compiles and tests pass
17+
5. **Verify nothing broke**: Run `pnpm run check` and `pnpm test` after each phase
18+
19+
**What to look for:**
20+
- Unused exports (exported but never imported elsewhere)
21+
- Dead imports (imported but never used)
22+
- Unreachable code paths
23+
- Duplicate logic that should be consolidated
24+
- Files >400 LOC that should be split (flag to user, don't split without approval)
25+
- Backward compatibility shims (FORBIDDEN per CLAUDE.md — actively remove)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
You are a security reviewer for Socket Security Node.js repositories.
2+
3+
Apply these rules from CLAUDE.md exactly:
4+
5+
**Safe File Operations**: Use safeDelete()/safeDeleteSync() from @socketsecurity/lib/fs. NEVER fs.rm(), fs.rmSync(), or rm -rf. NEVER use os.tmpdir() — use tempDir from @socketsecurity/lib/env/temp-dir.
6+
7+
**Absolute Rules**: NEVER use npx, pnpm dlx, or yarn dlx. Use pnpm exec or pnpm run with pinned devDeps.
8+
9+
**Work Safeguards**: Scripts modifying multiple files must have backup/rollback. Git operations that rewrite history require explicit confirmation.
10+
11+
**Review checklist:**
12+
13+
1. **Secrets**: Hardcoded API keys, passwords, tokens, private keys in code or config
14+
2. **Injection**: Command injection via shell: true or string interpolation in spawn/exec. Path traversal in file operations.
15+
3. **Dependencies**: npx/dlx usage. Unpinned versions (^ or ~). Missing minimumReleaseAge bypass justification.
16+
4. **File operations**: fs.rm without safeDelete. os.tmpdir usage. process.chdir usage.
17+
5. **GitHub Actions**: Unpinned action versions (must use full SHA). Secrets outside env blocks. Template injection from untrusted inputs.
18+
6. **Error handling**: Sensitive data in error messages. Stack traces exposed to users.
19+
20+
For each finding, report:
21+
- **Severity**: CRITICAL / HIGH / MEDIUM / LOW
22+
- **Location**: file:line
23+
- **Issue**: what's wrong
24+
- **Fix**: how to fix it
25+
26+
Run `pnpm audit` for dependency vulnerabilities. Run `pnpm run security` for config/workflow scanning.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Generate a changelog entry for the next release.
2+
3+
Follow the format from CLAUDE.md § "Changelog Management":
4+
- Format: `## [version](https://github.com/SocketDev/socket-registry/releases/tag/vversion) - YYYY-MM-DD`
5+
- Follow [Keep a Changelog](https://keepachangelog.com/)
6+
- Sections: Added, Changed, Fixed, Removed
7+
- User-facing changes only (no internal refactoring, deps, or CI)
8+
9+
Steps:
10+
1. Read current CHANGELOG.md to get the last released version
11+
2. Run `git log --oneline <last-tag>..HEAD` to see all commits since last release
12+
3. Categorize each commit into Added/Changed/Fixed/Removed
13+
4. Skip chore/ci/deps commits unless they affect user-facing behavior
14+
5. Determine version bump: feat → minor, fix → patch, breaking → major
15+
6. Write the new entry at the top of CHANGELOG.md
16+
7. Update version in package.json
17+
8. Present the changelog for review before committing

.claude/skills/ci-cascade/SKILL.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: ci-cascade
3+
description: Execute the GitHub Actions SHA pin cascade when a socket-registry action changes. Creates PRs in dependency order, waits for merges, and propagates the final SHA to all consuming repos.
4+
---
5+
6+
# CI SHA Pin Cascade
7+
8+
Implements the cascade procedure defined in CLAUDE.md § "GitHub Actions SHA Pin Cascade (CRITICAL)".
9+
10+
## When to Use
11+
12+
- After modifying any GitHub Action in `.github/actions/`
13+
- After modifying a reusable workflow in `.github/workflows/ci.yml` or `provenance.yml`
14+
- When a dependency (Node.js version, pnpm version, sfw-free) changes in an action
15+
16+
## Procedure
17+
18+
Follow the layer order exactly. Each layer gets its own PR. Never combine layers.
19+
20+
### Phase 1: Identify what changed
21+
22+
Determine which layer was modified:
23+
- Layer 1 (leaf actions): checkout, install, debug, setup-git-signing, cleanup-git-signing, run-script, artifacts, cache-npm-packages
24+
- Layer 2a (setup): references debug
25+
- Layer 2b (setup-and-install): references checkout, setup, install
26+
- Layer 3 (reusable workflows): ci.yml, provenance.yml
27+
- Layer 4 (local wrappers): _local-not-for-reuse-*
28+
29+
### Phase 2: Create PRs in order
30+
31+
Starting from the layer above the change, create a PR for each layer:
32+
33+
1. **Get current SHA**: `git fetch origin main && git rev-parse origin/main`
34+
2. **Create branch**: `git checkout -b chore/ci-cascade-layer-N`
35+
3. **Update refs**: Replace old SHA with new SHA in all files at this layer
36+
4. **Verify**: `grep -rn "SocketDev/socket-registry" .github/ | grep "@" | grep -v "<new-sha>"`
37+
5. **Don't clobber**: Never replace third-party SHAs (actions/checkout, actions/upload-artifact, etc.)
38+
6. **Commit**: `chore(ci): bump socket-registry action refs to main (<short-sha>)`
39+
7. **Push and create PR**
40+
8. **Wait for merge** before proceeding to next layer
41+
42+
### Phase 3: Propagate to external repos
43+
44+
The **propagation SHA** is the Layer 3 merge SHA (where ci.yml and provenance.yml were updated). All external repos pin to this same SHA.
45+
46+
External repos (update all):
47+
- socket-btm, socket-cli, socket-sdk-js, socket-packageurl-js
48+
- socket-sbom-generator, socket-lib, ultrathink
49+
50+
For each repo:
51+
1. Update all `SocketDev/socket-registry/.github/` refs to the propagation SHA
52+
2. Push directly to main where allowed
53+
3. Create PRs where branch protection requires it
54+
55+
### Phase 4: Verify
56+
57+
For each updated repo, confirm no old SHAs remain:
58+
```bash
59+
grep -rn "SocketDev/socket-registry" .github/ | grep "@" | grep -v "<propagation-sha>"
60+
```

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ WIP
1919

2020
# Claude Code scratch files
2121
/.claude/*
22-
!/.claude/skills/
22+
!/.claude/agents/
2323
!/.claude/commands/
24+
!/.claude/skills/
2425

2526
# Environment files
2627
/.env

0 commit comments

Comments
 (0)