feat: enhance Claude Code setup with slash commands, hooks, and verification

Add slash commands for common workflows:
- /commit-push-pr: Streamlined PR creation
- /verify: Full verification suite (lint + test + build)
- /test: Run tests with results summary
- /lint-fix: Auto-fix lint and formatting
- /review: Code review for quality and Nostr patterns

Update settings.json:
- Expand permissions for common safe bash commands
- Add PostToolUse hook for auto-formatting with Prettier

Update CLAUDE.md:
- Add Verification Requirements section
- Document available slash commands
- Emphasize running /verify before PRs
This commit is contained in:
Claude
2026-01-05 11:30:43 +00:00
parent f22cfc930f
commit 148a1ef999
7 changed files with 139 additions and 3 deletions

View File

@@ -0,0 +1,17 @@
Create a PR for the current changes.
Git status: ${{ git status --short }}
Current branch: ${{ git branch --show-current }}
Diff stats: ${{ git diff --stat HEAD~1 2>/dev/null || git diff --stat }}
Recent commits: ${{ git log --oneline -5 }}
Instructions:
1. Review the changes and stage relevant files
2. Create a commit with a clear, descriptive message following repo conventions
3. Push to the current branch (or create a new branch if on main)
4. Create a PR with:
- Clear title summarizing the change
- Summary section with bullet points
- Test plan section describing how to verify
Do NOT push to main/master directly.

View File

@@ -0,0 +1,10 @@
Fix all lint and formatting issues in the codebase.
Run in sequence:
1. `npm run lint:fix` - Auto-fix ESLint issues
2. `npm run format` - Format with Prettier
Report:
- Number of files fixed
- Any issues that couldn't be auto-fixed (require manual intervention)
- Summary of what was changed

View File

@@ -0,0 +1,34 @@
Review the code changes for quality and Nostr best practices.
Diff to review: ${{ git diff }}
Analyze the changes for:
## 1. Nostr Protocol Compliance
- Correct event kinds used for the feature
- Proper tag structures (NIP-10 threading, NIP-19 identifiers, etc.)
- Appropriate handling of replaceable vs regular events
## 2. Applesauce Patterns
- Using EventStore singleton (not creating new instances)
- NOT wrapping applesauce helpers in useMemo (they cache internally)
- Proper subscription cleanup in useEffect
- Using reactive patterns (observables) correctly
## 3. React Best Practices
- No missing dependencies in useEffect/useMemo/useCallback
- Proper cleanup functions in useEffect
- No unnecessary re-renders or state updates
## 4. Code Quality
- Follows existing patterns in the codebase
- No over-engineering or unnecessary abstractions
- Security considerations (XSS prevention, input validation)
- Proper error handling where needed
## 5. Architecture Alignment
- Uses path alias (@/) correctly
- Follows file organization conventions
- State mutations go through logic.ts pure functions
Provide specific, actionable feedback with `file:line` references.

11
.claude/commands/test.md Normal file
View File

@@ -0,0 +1,11 @@
Run the test suite and report results.
Changed files: ${{ git diff --name-only HEAD 2>/dev/null || echo "(no changes)" }}
Run `npm run test:run` and provide:
- Total tests: passed/failed/skipped
- Any failing tests with error messages
- Suggestions for fixing failures
If a specific test file is provided as an argument, run only that file:
`npm run test:run -- <file>`

View File

@@ -0,0 +1,16 @@
Run full verification suite for the current changes.
Execute these checks in sequence, stopping on first failure:
1. **Lint Check**: `npm run lint`
2. **Test Suite**: `npm run test:run`
3. **Build Check**: `npm run build`
For each step:
- If it passes, proceed to the next
- If it fails, report the specific errors and suggest fixes
After all checks pass, summarize:
- Total tests run and passed
- Any warnings to be aware of
- Confirmation that the changes are ready for PR

View File

@@ -2,6 +2,7 @@
"permissions": {
"allow": [
"Bash(npm:*)",
"Bash(npx:*)",
"Bash(git:*)",
"Bash(gh:*)",
"Bash(find:*)",
@@ -18,9 +19,31 @@
"Bash(source ~/.zshrc)",
"Bash(nvm use:*)",
"Bash(nvm install:*)",
"Bash(node --version:*)"
"Bash(node --version:*)",
"Bash(mkdir:*)",
"Bash(cp:*)",
"Bash(mv:*)",
"Bash(rm:*)",
"Bash(touch:*)",
"Bash(pwd)",
"Bash(which:*)",
"Bash(echo:*)",
"Bash(curl:*)",
"Bash(jq:*)"
],
"deny": [],
"ask": []
"deny": []
},
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$FILEPATH\" 2>/dev/null || true"
}
]
}
]
}
}

View File

@@ -195,6 +195,30 @@ describe("parseReqCommand", () => {
});
```
## Verification Requirements
**CRITICAL**: Before marking any task complete, verify changes work correctly:
1. **For any code change**: Run `npm run test:run` - tests must pass
2. **For UI changes**: Run `npm run build` - build must succeed
3. **For style/lint changes**: Run `npm run lint` - no new errors
**Quick verification command**:
```bash
npm run lint && npm run test:run && npm run build
```
If tests fail, fix the issues before proceeding. Never leave broken tests or a failing build.
### Slash Commands
Use these commands for common workflows:
- `/verify` - Run full verification suite (lint + test + build)
- `/test` - Run tests and report results
- `/lint-fix` - Auto-fix lint and formatting issues
- `/commit-push-pr` - Create a commit and PR with proper formatting
- `/review` - Review changes for quality and Nostr best practices
## Critical Notes
- React 19 features in use (ensure compatibility)
@@ -202,3 +226,4 @@ describe("parseReqCommand", () => {
- Dark mode is default (controlled via HTML class)
- EventStore handles event deduplication and replaceability automatically
- Run tests before committing changes to parsers or core logic
- Always run `/verify` before creating a PR