.factory/skills/refactor-worker/SKILL.md
Refactors TypeScript code while preserving functionality, ensuring files stay under 200 lines
npx skillsauth add 0xsero/parchi refactor-workerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.
Use this worker for refactoring features that involve:
Read the feature description carefully. Identify:
Before making changes:
# Run all unit tests (NOTE: --grep filters are ignored by the current test runner)
npm run test:unit
# Check current file sizes
wc -l <files-to-refactor>
# Run typecheck
npm run typecheck
Document any pre-existing test failures or issues.
IMPORTANT: The unit test runner (tests/unit/run-unit-tests.ts) hard-codes suite registration and ignores CLI grep filters. To test specific functionality, add a focused test suite that tests exactly what you need.
If tests don't exist for the code being refactored:
If tests exist:
Make small, focused changes:
After refactoring:
# Check all affected files are <= 200 lines
wc -l <affected-files>
# If any file is over 200 lines, continue splitting
Ensure all imports are updated:
# Full typecheck
npm run typecheck
# Run all related tests
npm run test:unit
npm run test:integration
# Lint check
npm run lint
# Repo standards check (file size limits, etc.)
npm run check:repo-standards
# Build check
npm run build
# Final diff review - check what files will be committed
git diff --cached --stat
git diff --stat
CRITICAL - Final Diff Review Checklist:
Before marking the feature complete, verify:
If version bumps are detected:
git reset HEAD package.json packages/extension/manifest*.json--no-verify to bypass auto-bumping hooksIf any file exceeds 200 lines:
IMPORTANT: Only set followedProcedure: true in the handoff if ALL validation steps were actually run and passed. Record the actual commands and their output in the handoff.
Update any affected:
{
"salientSummary": "Refactored panel-core.ts (1541 lines) into 6 focused modules: trace-sanitizer.ts (89 lines), history-manager.ts (112 lines), message-processor.ts (145 lines), state-manager.ts (98 lines), event-handler.ts (134 lines), and panel-core.ts (167 lines). All tests pass, typecheck clean, build succeeds.",
"whatWasImplemented": "Split panel-core.ts into 6 modules with clear responsibilities. Extracted trace sanitization logic, history management, message processing, state management, and event handling into separate files. Updated all imports in sidepanel UI. Added unit tests for trace-sanitizer.ts and history-manager.ts.",
"whatWasLeftUndone": "",
"verification": {
"commandsRun": [
{
"command": "npm run typecheck",
"exitCode": 0,
"observation": "No TypeScript errors"
},
{
"command": "npm run test:unit -- --grep 'panel-core'",
"exitCode": 0,
"observation": "23 tests passed"
},
{
"command": "wc -l packages/extension/sidepanel/ui/core/*.ts",
"exitCode": 0,
"observation": "All files under 200 lines, largest is panel-core.ts at 167 lines"
},
{
"command": "npm run build",
"exitCode": 0,
"observation": "Build succeeded, dist/ updated"
}
],
"interactiveChecks": [
{
"action": "Loaded extension in Chrome and opened sidepanel",
"observed": "UI renders correctly, chat works, settings accessible"
}
]
},
"tests": {
"added": [
{
"file": "tests/unit/trace-sanitizer.test.ts",
"cases": [
{"name": "sanitizes long strings", "verifies": "VAL-QUALITY-002"},
{"name": "handles circular references", "verifies": "VAL-QUALITY-002"},
{"name": "caps array items", "verifies": "VAL-QUALITY-002"}
]
}
]
},
"discoveredIssues": []
}
Return to the orchestrator if:
tools
Use Parchi Relay to control a real browser via the Parchi extension agent (WebSocket) or directly via JSON-RPC from a CLI/tooling workflow.
development
Validates refactored code through testing, coverage analysis, and quality gate checks
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.