diff --git a/.claude/commands/commit-push-pr.md b/.claude/commands/commit-push-pr.md new file mode 100644 index 0000000..6a1b298 --- /dev/null +++ b/.claude/commands/commit-push-pr.md @@ -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. diff --git a/.claude/commands/lint-fix.md b/.claude/commands/lint-fix.md new file mode 100644 index 0000000..68a892f --- /dev/null +++ b/.claude/commands/lint-fix.md @@ -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 diff --git a/.claude/commands/review.md b/.claude/commands/review.md new file mode 100644 index 0000000..abc743c --- /dev/null +++ b/.claude/commands/review.md @@ -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. diff --git a/.claude/commands/test.md b/.claude/commands/test.md new file mode 100644 index 0000000..746d47d --- /dev/null +++ b/.claude/commands/test.md @@ -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 -- ` diff --git a/.claude/commands/verify.md b/.claude/commands/verify.md new file mode 100644 index 0000000..22e92da --- /dev/null +++ b/.claude/commands/verify.md @@ -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 diff --git a/.claude/settings.json b/.claude/settings.json index f277760..2732313 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -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" + } + ] + } + ] } } diff --git a/CLAUDE.md b/CLAUDE.md index 1ed6558..1f6f13e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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