devflow-kit 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -29
- package/LICENSE +1 -1
- package/README.md +179 -310
- package/dist/cli.js +3 -1
- package/dist/commands/init.d.ts +21 -0
- package/dist/commands/init.js +311 -576
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.js +20 -0
- package/dist/commands/uninstall.d.ts +10 -0
- package/dist/commands/uninstall.js +351 -78
- package/dist/plugins.d.ts +46 -0
- package/dist/plugins.js +162 -0
- package/dist/utils/cli.d.ts +5 -0
- package/dist/utils/cli.js +14 -0
- package/dist/utils/installer.d.ts +41 -0
- package/dist/utils/installer.js +177 -0
- package/dist/utils/paths.d.ts +10 -0
- package/dist/utils/paths.js +23 -3
- package/dist/utils/post-install.d.ts +68 -0
- package/dist/utils/post-install.js +427 -0
- package/dist/utils/safe-delete-install.d.ts +22 -0
- package/dist/utils/safe-delete-install.js +156 -0
- package/dist/utils/safe-delete.d.ts +12 -0
- package/dist/utils/safe-delete.js +83 -0
- package/package.json +18 -8
- package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +7 -0
- package/plugins/devflow-audit-claude/README.md +46 -0
- package/plugins/devflow-audit-claude/agents/claude-md-auditor.md +134 -0
- package/plugins/devflow-audit-claude/commands/audit-claude.md +85 -0
- package/plugins/devflow-code-review/.claude-plugin/plugin.json +31 -0
- package/plugins/devflow-code-review/README.md +73 -0
- package/plugins/devflow-code-review/agents/git.md +272 -0
- package/plugins/devflow-code-review/agents/reviewer.md +119 -0
- package/plugins/devflow-code-review/agents/synthesizer.md +204 -0
- package/plugins/devflow-code-review/commands/code-review-teams.md +262 -0
- package/plugins/devflow-code-review/commands/code-review.md +141 -0
- package/plugins/devflow-code-review/skills/accessibility/SKILL.md +229 -0
- package/plugins/devflow-code-review/skills/accessibility/references/detection.md +171 -0
- package/plugins/devflow-code-review/skills/accessibility/references/patterns.md +670 -0
- package/plugins/devflow-code-review/skills/accessibility/references/violations.md +419 -0
- package/plugins/devflow-code-review/skills/agent-teams/SKILL.md +124 -0
- package/plugins/devflow-code-review/skills/agent-teams/references/cleanup.md +104 -0
- package/plugins/devflow-code-review/skills/agent-teams/references/communication.md +122 -0
- package/plugins/devflow-code-review/skills/agent-teams/references/team-patterns.md +217 -0
- package/plugins/devflow-code-review/skills/architecture-patterns/SKILL.md +153 -0
- package/plugins/devflow-code-review/skills/architecture-patterns/references/detection.md +337 -0
- package/plugins/devflow-code-review/skills/architecture-patterns/references/patterns.md +873 -0
- package/plugins/devflow-code-review/skills/architecture-patterns/references/violations.md +575 -0
- package/plugins/devflow-code-review/skills/complexity-patterns/SKILL.md +143 -0
- package/plugins/devflow-code-review/skills/complexity-patterns/references/detection.md +264 -0
- package/plugins/devflow-code-review/skills/complexity-patterns/references/patterns.md +487 -0
- package/plugins/devflow-code-review/skills/complexity-patterns/references/violations.md +361 -0
- package/plugins/devflow-code-review/skills/consistency-patterns/SKILL.md +140 -0
- package/plugins/devflow-code-review/skills/consistency-patterns/references/detection.md +207 -0
- package/plugins/devflow-code-review/skills/consistency-patterns/references/patterns.md +202 -0
- package/plugins/devflow-code-review/skills/consistency-patterns/references/violations.md +213 -0
- package/plugins/devflow-code-review/skills/database-patterns/SKILL.md +134 -0
- package/plugins/devflow-code-review/skills/database-patterns/references/detection.md +208 -0
- package/plugins/devflow-code-review/skills/database-patterns/references/patterns.md +394 -0
- package/plugins/devflow-code-review/skills/database-patterns/references/violations.md +332 -0
- package/plugins/devflow-code-review/skills/dependencies-patterns/SKILL.md +141 -0
- package/plugins/devflow-code-review/skills/dependencies-patterns/references/detection.md +181 -0
- package/plugins/devflow-code-review/skills/dependencies-patterns/references/patterns.md +225 -0
- package/plugins/devflow-code-review/skills/dependencies-patterns/references/violations.md +247 -0
- package/plugins/devflow-code-review/skills/documentation-patterns/SKILL.md +125 -0
- package/plugins/devflow-code-review/skills/documentation-patterns/references/detection.md +190 -0
- package/plugins/devflow-code-review/skills/documentation-patterns/references/patterns.md +189 -0
- package/plugins/devflow-code-review/skills/documentation-patterns/references/violations.md +163 -0
- package/plugins/devflow-code-review/skills/frontend-design/SKILL.md +254 -0
- package/plugins/devflow-code-review/skills/frontend-design/references/detection.md +184 -0
- package/plugins/devflow-code-review/skills/frontend-design/references/patterns.md +511 -0
- package/plugins/devflow-code-review/skills/frontend-design/references/violations.md +453 -0
- package/plugins/devflow-code-review/skills/performance-patterns/SKILL.md +154 -0
- package/plugins/devflow-code-review/skills/performance-patterns/references/detection.md +351 -0
- package/plugins/devflow-code-review/skills/performance-patterns/references/patterns.md +503 -0
- package/plugins/devflow-code-review/skills/performance-patterns/references/violations.md +354 -0
- package/plugins/devflow-code-review/skills/react/SKILL.md +276 -0
- package/plugins/devflow-code-review/skills/react/references/patterns.md +1331 -0
- package/plugins/devflow-code-review/skills/react/references/violations.md +565 -0
- package/plugins/devflow-code-review/skills/regression-patterns/SKILL.md +146 -0
- package/plugins/devflow-code-review/skills/regression-patterns/references/detection.md +237 -0
- package/plugins/devflow-code-review/skills/regression-patterns/references/patterns.md +226 -0
- package/plugins/devflow-code-review/skills/regression-patterns/references/violations.md +225 -0
- package/plugins/devflow-code-review/skills/review-methodology/SKILL.md +119 -0
- package/plugins/devflow-code-review/skills/review-methodology/references/patterns.md +186 -0
- package/plugins/devflow-code-review/skills/review-methodology/references/report-template.md +142 -0
- package/plugins/devflow-code-review/skills/review-methodology/references/violations.md +125 -0
- package/plugins/devflow-code-review/skills/security-patterns/SKILL.md +156 -0
- package/plugins/devflow-code-review/skills/security-patterns/references/detection.md +287 -0
- package/plugins/devflow-code-review/skills/security-patterns/references/patterns.md +507 -0
- package/plugins/devflow-code-review/skills/security-patterns/references/violations.md +237 -0
- package/plugins/devflow-code-review/skills/test-patterns/SKILL.md +183 -0
- package/plugins/devflow-code-review/skills/test-patterns/references/detection.md +149 -0
- package/plugins/devflow-code-review/skills/test-patterns/references/patterns.md +220 -0
- package/plugins/devflow-code-review/skills/test-patterns/references/report-template.md +108 -0
- package/plugins/devflow-code-review/skills/test-patterns/references/violations.md +221 -0
- package/plugins/devflow-core-skills/.claude-plugin/plugin.json +27 -0
- package/plugins/devflow-core-skills/README.md +50 -0
- package/plugins/devflow-core-skills/skills/accessibility/SKILL.md +229 -0
- package/plugins/devflow-core-skills/skills/accessibility/references/detection.md +171 -0
- package/plugins/devflow-core-skills/skills/accessibility/references/patterns.md +670 -0
- package/plugins/devflow-core-skills/skills/accessibility/references/violations.md +419 -0
- package/plugins/devflow-core-skills/skills/core-patterns/SKILL.md +162 -0
- package/plugins/devflow-core-skills/skills/core-patterns/references/checklist.md +276 -0
- package/plugins/devflow-core-skills/skills/core-patterns/references/code-smell-violations.md +144 -0
- package/plugins/devflow-core-skills/skills/core-patterns/references/detection.md +303 -0
- package/plugins/devflow-core-skills/skills/core-patterns/references/patterns.md +576 -0
- package/plugins/devflow-core-skills/skills/core-patterns/references/violations.md +369 -0
- package/plugins/devflow-core-skills/skills/docs-framework/SKILL.md +134 -0
- package/plugins/devflow-core-skills/skills/docs-framework/references/patterns.md +346 -0
- package/plugins/devflow-core-skills/skills/docs-framework/references/violations.md +221 -0
- package/plugins/devflow-core-skills/skills/frontend-design/SKILL.md +254 -0
- package/plugins/devflow-core-skills/skills/frontend-design/references/detection.md +184 -0
- package/plugins/devflow-core-skills/skills/frontend-design/references/patterns.md +511 -0
- package/plugins/devflow-core-skills/skills/frontend-design/references/violations.md +453 -0
- package/plugins/devflow-core-skills/skills/git-safety/SKILL.md +122 -0
- package/plugins/devflow-core-skills/skills/git-safety/references/detection.md +290 -0
- package/plugins/devflow-core-skills/skills/git-safety/references/patterns.md +289 -0
- package/plugins/devflow-core-skills/skills/git-safety/references/violations.md +18 -0
- package/plugins/devflow-core-skills/skills/git-workflow/SKILL.md +158 -0
- package/plugins/devflow-core-skills/skills/git-workflow/references/commit-patterns.md +115 -0
- package/plugins/devflow-core-skills/skills/git-workflow/references/commit-violations.md +77 -0
- package/plugins/devflow-core-skills/skills/git-workflow/references/pr-patterns.md +127 -0
- package/plugins/devflow-core-skills/skills/git-workflow/references/pr-violations.md +96 -0
- package/plugins/devflow-core-skills/skills/github-patterns/SKILL.md +153 -0
- package/plugins/devflow-core-skills/skills/github-patterns/references/patterns.md +572 -0
- package/plugins/devflow-core-skills/skills/github-patterns/references/violations.md +298 -0
- package/plugins/devflow-core-skills/skills/input-validation/SKILL.md +148 -0
- package/plugins/devflow-core-skills/skills/input-validation/references/detection.md +283 -0
- package/plugins/devflow-core-skills/skills/input-validation/references/patterns.md +361 -0
- package/plugins/devflow-core-skills/skills/input-validation/references/violations.md +224 -0
- package/plugins/devflow-core-skills/skills/react/SKILL.md +276 -0
- package/plugins/devflow-core-skills/skills/react/references/patterns.md +1331 -0
- package/plugins/devflow-core-skills/skills/react/references/violations.md +565 -0
- package/plugins/devflow-core-skills/skills/test-patterns/SKILL.md +183 -0
- package/plugins/devflow-core-skills/skills/test-patterns/references/detection.md +149 -0
- package/plugins/devflow-core-skills/skills/test-patterns/references/patterns.md +220 -0
- package/plugins/devflow-core-skills/skills/test-patterns/references/report-template.md +108 -0
- package/plugins/devflow-core-skills/skills/test-patterns/references/violations.md +221 -0
- package/plugins/devflow-core-skills/skills/typescript/SKILL.md +176 -0
- package/plugins/devflow-core-skills/skills/typescript/references/patterns.md +1105 -0
- package/plugins/devflow-core-skills/skills/typescript/references/violations.md +433 -0
- package/plugins/devflow-debug/.claude-plugin/plugin.json +18 -0
- package/plugins/devflow-debug/README.md +65 -0
- package/plugins/devflow-debug/agents/git.md +272 -0
- package/plugins/devflow-debug/commands/debug-teams.md +231 -0
- package/plugins/devflow-debug/commands/debug.md +160 -0
- package/plugins/devflow-debug/skills/agent-teams/SKILL.md +124 -0
- package/plugins/devflow-debug/skills/agent-teams/references/cleanup.md +104 -0
- package/plugins/devflow-debug/skills/agent-teams/references/communication.md +122 -0
- package/plugins/devflow-debug/skills/agent-teams/references/team-patterns.md +217 -0
- package/plugins/devflow-debug/skills/git-safety/SKILL.md +122 -0
- package/plugins/devflow-debug/skills/git-safety/references/detection.md +290 -0
- package/plugins/devflow-debug/skills/git-safety/references/patterns.md +289 -0
- package/plugins/devflow-debug/skills/git-safety/references/violations.md +18 -0
- package/plugins/devflow-implement/.claude-plugin/plugin.json +21 -0
- package/plugins/devflow-implement/README.md +71 -0
- package/plugins/devflow-implement/agents/coder.md +122 -0
- package/plugins/devflow-implement/agents/git.md +272 -0
- package/plugins/devflow-implement/agents/scrutinizer.md +80 -0
- package/plugins/devflow-implement/agents/shepherd.md +94 -0
- package/plugins/devflow-implement/agents/simplifier.md +62 -0
- package/plugins/devflow-implement/agents/skimmer.md +88 -0
- package/plugins/devflow-implement/agents/synthesizer.md +204 -0
- package/plugins/devflow-implement/agents/validator.md +86 -0
- package/plugins/devflow-implement/commands/implement-teams.md +608 -0
- package/plugins/devflow-implement/commands/implement.md +426 -0
- package/plugins/devflow-implement/skills/accessibility/SKILL.md +229 -0
- package/plugins/devflow-implement/skills/accessibility/references/detection.md +171 -0
- package/plugins/devflow-implement/skills/accessibility/references/patterns.md +670 -0
- package/plugins/devflow-implement/skills/accessibility/references/violations.md +419 -0
- package/plugins/devflow-implement/skills/agent-teams/SKILL.md +124 -0
- package/plugins/devflow-implement/skills/agent-teams/references/cleanup.md +104 -0
- package/plugins/devflow-implement/skills/agent-teams/references/communication.md +122 -0
- package/plugins/devflow-implement/skills/agent-teams/references/team-patterns.md +217 -0
- package/plugins/devflow-implement/skills/frontend-design/SKILL.md +254 -0
- package/plugins/devflow-implement/skills/frontend-design/references/detection.md +184 -0
- package/plugins/devflow-implement/skills/frontend-design/references/patterns.md +511 -0
- package/plugins/devflow-implement/skills/frontend-design/references/violations.md +453 -0
- package/plugins/devflow-implement/skills/implementation-patterns/SKILL.md +162 -0
- package/plugins/devflow-implement/skills/implementation-patterns/references/patterns.md +1063 -0
- package/plugins/devflow-implement/skills/implementation-patterns/references/violations.md +483 -0
- package/plugins/devflow-implement/skills/self-review/SKILL.md +149 -0
- package/plugins/devflow-implement/skills/self-review/references/patterns.md +405 -0
- package/plugins/devflow-implement/skills/self-review/references/report-template.md +253 -0
- package/plugins/devflow-implement/skills/self-review/references/violations.md +308 -0
- package/plugins/devflow-resolve/.claude-plugin/plugin.json +19 -0
- package/plugins/devflow-resolve/README.md +65 -0
- package/plugins/devflow-resolve/agents/git.md +272 -0
- package/plugins/devflow-resolve/agents/resolver.md +131 -0
- package/plugins/devflow-resolve/agents/simplifier.md +62 -0
- package/plugins/devflow-resolve/commands/resolve-teams.md +298 -0
- package/plugins/devflow-resolve/commands/resolve.md +237 -0
- package/plugins/devflow-resolve/skills/agent-teams/SKILL.md +124 -0
- package/plugins/devflow-resolve/skills/agent-teams/references/cleanup.md +104 -0
- package/plugins/devflow-resolve/skills/agent-teams/references/communication.md +122 -0
- package/plugins/devflow-resolve/skills/agent-teams/references/team-patterns.md +217 -0
- package/plugins/devflow-resolve/skills/implementation-patterns/SKILL.md +162 -0
- package/plugins/devflow-resolve/skills/implementation-patterns/references/patterns.md +1063 -0
- package/plugins/devflow-resolve/skills/implementation-patterns/references/violations.md +483 -0
- package/plugins/devflow-resolve/skills/security-patterns/SKILL.md +156 -0
- package/plugins/devflow-resolve/skills/security-patterns/references/detection.md +287 -0
- package/plugins/devflow-resolve/skills/security-patterns/references/patterns.md +507 -0
- package/plugins/devflow-resolve/skills/security-patterns/references/violations.md +237 -0
- package/plugins/devflow-self-review/.claude-plugin/plugin.json +7 -0
- package/plugins/devflow-self-review/README.md +38 -0
- package/plugins/devflow-self-review/agents/scrutinizer.md +80 -0
- package/plugins/devflow-self-review/agents/simplifier.md +62 -0
- package/plugins/devflow-self-review/agents/validator.md +86 -0
- package/plugins/devflow-self-review/commands/self-review.md +126 -0
- package/plugins/devflow-self-review/skills/core-patterns/SKILL.md +162 -0
- package/plugins/devflow-self-review/skills/core-patterns/references/checklist.md +276 -0
- package/plugins/devflow-self-review/skills/core-patterns/references/code-smell-violations.md +144 -0
- package/plugins/devflow-self-review/skills/core-patterns/references/detection.md +303 -0
- package/plugins/devflow-self-review/skills/core-patterns/references/patterns.md +576 -0
- package/plugins/devflow-self-review/skills/core-patterns/references/violations.md +369 -0
- package/plugins/devflow-self-review/skills/self-review/SKILL.md +149 -0
- package/plugins/devflow-self-review/skills/self-review/references/patterns.md +405 -0
- package/plugins/devflow-self-review/skills/self-review/references/report-template.md +253 -0
- package/plugins/devflow-self-review/skills/self-review/references/violations.md +308 -0
- package/plugins/devflow-specify/.claude-plugin/plugin.json +15 -0
- package/plugins/devflow-specify/README.md +46 -0
- package/plugins/devflow-specify/agents/skimmer.md +88 -0
- package/plugins/devflow-specify/agents/synthesizer.md +204 -0
- package/plugins/devflow-specify/commands/specify-teams.md +314 -0
- package/plugins/devflow-specify/commands/specify.md +179 -0
- package/plugins/devflow-specify/skills/agent-teams/SKILL.md +124 -0
- package/plugins/devflow-specify/skills/agent-teams/references/cleanup.md +104 -0
- package/plugins/devflow-specify/skills/agent-teams/references/communication.md +122 -0
- package/plugins/devflow-specify/skills/agent-teams/references/team-patterns.md +217 -0
- package/scripts/hooks/background-memory-update.sh +167 -0
- package/scripts/hooks/pre-compact-memory.sh +81 -0
- package/scripts/hooks/session-start-memory.sh +84 -0
- package/scripts/hooks/stop-update-memory.sh +81 -0
- package/shared/agents/coder.md +122 -0
- package/shared/agents/git.md +272 -0
- package/shared/agents/resolver.md +131 -0
- package/shared/agents/reviewer.md +119 -0
- package/shared/agents/scrutinizer.md +80 -0
- package/shared/agents/shepherd.md +94 -0
- package/shared/agents/simplifier.md +62 -0
- package/shared/agents/skimmer.md +88 -0
- package/shared/agents/synthesizer.md +204 -0
- package/shared/agents/validator.md +86 -0
- package/shared/skills/accessibility/SKILL.md +229 -0
- package/shared/skills/accessibility/references/detection.md +171 -0
- package/shared/skills/accessibility/references/patterns.md +670 -0
- package/shared/skills/accessibility/references/violations.md +419 -0
- package/shared/skills/agent-teams/SKILL.md +124 -0
- package/shared/skills/agent-teams/references/cleanup.md +104 -0
- package/shared/skills/agent-teams/references/communication.md +122 -0
- package/shared/skills/agent-teams/references/team-patterns.md +217 -0
- package/shared/skills/architecture-patterns/SKILL.md +153 -0
- package/shared/skills/architecture-patterns/references/detection.md +337 -0
- package/shared/skills/architecture-patterns/references/patterns.md +873 -0
- package/shared/skills/architecture-patterns/references/violations.md +575 -0
- package/shared/skills/complexity-patterns/SKILL.md +143 -0
- package/shared/skills/complexity-patterns/references/detection.md +264 -0
- package/shared/skills/complexity-patterns/references/patterns.md +487 -0
- package/shared/skills/complexity-patterns/references/violations.md +361 -0
- package/shared/skills/consistency-patterns/SKILL.md +140 -0
- package/shared/skills/consistency-patterns/references/detection.md +207 -0
- package/shared/skills/consistency-patterns/references/patterns.md +202 -0
- package/shared/skills/consistency-patterns/references/violations.md +213 -0
- package/shared/skills/core-patterns/SKILL.md +162 -0
- package/shared/skills/core-patterns/references/checklist.md +276 -0
- package/shared/skills/core-patterns/references/code-smell-violations.md +144 -0
- package/shared/skills/core-patterns/references/detection.md +303 -0
- package/shared/skills/core-patterns/references/patterns.md +576 -0
- package/shared/skills/core-patterns/references/violations.md +369 -0
- package/shared/skills/database-patterns/SKILL.md +134 -0
- package/shared/skills/database-patterns/references/detection.md +208 -0
- package/shared/skills/database-patterns/references/patterns.md +394 -0
- package/shared/skills/database-patterns/references/violations.md +332 -0
- package/shared/skills/dependencies-patterns/SKILL.md +141 -0
- package/shared/skills/dependencies-patterns/references/detection.md +181 -0
- package/shared/skills/dependencies-patterns/references/patterns.md +225 -0
- package/shared/skills/dependencies-patterns/references/violations.md +247 -0
- package/shared/skills/docs-framework/SKILL.md +134 -0
- package/shared/skills/docs-framework/references/patterns.md +346 -0
- package/shared/skills/docs-framework/references/violations.md +221 -0
- package/shared/skills/documentation-patterns/SKILL.md +125 -0
- package/shared/skills/documentation-patterns/references/detection.md +190 -0
- package/shared/skills/documentation-patterns/references/patterns.md +189 -0
- package/shared/skills/documentation-patterns/references/violations.md +163 -0
- package/shared/skills/frontend-design/SKILL.md +254 -0
- package/shared/skills/frontend-design/references/detection.md +184 -0
- package/shared/skills/frontend-design/references/patterns.md +511 -0
- package/shared/skills/frontend-design/references/violations.md +453 -0
- package/shared/skills/git-safety/SKILL.md +122 -0
- package/shared/skills/git-safety/references/detection.md +290 -0
- package/shared/skills/git-safety/references/patterns.md +289 -0
- package/shared/skills/git-safety/references/violations.md +18 -0
- package/shared/skills/git-workflow/SKILL.md +158 -0
- package/shared/skills/git-workflow/references/commit-patterns.md +115 -0
- package/shared/skills/git-workflow/references/commit-violations.md +77 -0
- package/shared/skills/git-workflow/references/pr-patterns.md +127 -0
- package/shared/skills/git-workflow/references/pr-violations.md +96 -0
- package/shared/skills/github-patterns/SKILL.md +153 -0
- package/shared/skills/github-patterns/references/patterns.md +572 -0
- package/shared/skills/github-patterns/references/violations.md +298 -0
- package/shared/skills/implementation-patterns/SKILL.md +162 -0
- package/shared/skills/implementation-patterns/references/patterns.md +1063 -0
- package/shared/skills/implementation-patterns/references/violations.md +483 -0
- package/shared/skills/input-validation/SKILL.md +148 -0
- package/shared/skills/input-validation/references/detection.md +283 -0
- package/shared/skills/input-validation/references/patterns.md +361 -0
- package/shared/skills/input-validation/references/violations.md +224 -0
- package/shared/skills/performance-patterns/SKILL.md +154 -0
- package/shared/skills/performance-patterns/references/detection.md +351 -0
- package/shared/skills/performance-patterns/references/patterns.md +503 -0
- package/shared/skills/performance-patterns/references/violations.md +354 -0
- package/shared/skills/react/SKILL.md +276 -0
- package/shared/skills/react/references/patterns.md +1331 -0
- package/shared/skills/react/references/violations.md +565 -0
- package/shared/skills/regression-patterns/SKILL.md +146 -0
- package/shared/skills/regression-patterns/references/detection.md +237 -0
- package/shared/skills/regression-patterns/references/patterns.md +226 -0
- package/shared/skills/regression-patterns/references/violations.md +225 -0
- package/shared/skills/review-methodology/SKILL.md +119 -0
- package/shared/skills/review-methodology/references/patterns.md +186 -0
- package/shared/skills/review-methodology/references/report-template.md +142 -0
- package/shared/skills/review-methodology/references/violations.md +125 -0
- package/shared/skills/security-patterns/SKILL.md +156 -0
- package/shared/skills/security-patterns/references/detection.md +287 -0
- package/shared/skills/security-patterns/references/patterns.md +507 -0
- package/shared/skills/security-patterns/references/violations.md +237 -0
- package/shared/skills/self-review/SKILL.md +149 -0
- package/shared/skills/self-review/references/patterns.md +405 -0
- package/shared/skills/self-review/references/report-template.md +253 -0
- package/shared/skills/self-review/references/violations.md +308 -0
- package/shared/skills/test-patterns/SKILL.md +183 -0
- package/shared/skills/test-patterns/references/detection.md +149 -0
- package/shared/skills/test-patterns/references/patterns.md +220 -0
- package/shared/skills/test-patterns/references/report-template.md +108 -0
- package/shared/skills/test-patterns/references/violations.md +221 -0
- package/shared/skills/typescript/SKILL.md +176 -0
- package/shared/skills/typescript/references/patterns.md +1105 -0
- package/shared/skills/typescript/references/violations.md +433 -0
- package/src/templates/claudeignore.template +188 -0
- package/src/templates/managed-settings.json +146 -0
- package/src/templates/settings.json +59 -0
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/uninstall.d.ts.map +0 -1
- package/dist/commands/uninstall.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/src/claude/CLAUDE.md +0 -400
- package/src/claude/agents/devflow/audit-architecture.md +0 -132
- package/src/claude/agents/devflow/audit-complexity.md +0 -132
- package/src/claude/agents/devflow/audit-database.md +0 -132
- package/src/claude/agents/devflow/audit-dependencies.md +0 -132
- package/src/claude/agents/devflow/audit-documentation.md +0 -132
- package/src/claude/agents/devflow/audit-performance.md +0 -256
- package/src/claude/agents/devflow/audit-security.md +0 -259
- package/src/claude/agents/devflow/audit-tests.md +0 -132
- package/src/claude/agents/devflow/audit-typescript.md +0 -132
- package/src/claude/agents/devflow/brainstorm.md +0 -279
- package/src/claude/agents/devflow/catch-up.md +0 -345
- package/src/claude/agents/devflow/code-review.md +0 -307
- package/src/claude/agents/devflow/commit.md +0 -380
- package/src/claude/agents/devflow/debug.md +0 -476
- package/src/claude/agents/devflow/design.md +0 -491
- package/src/claude/agents/devflow/get-issue.md +0 -286
- package/src/claude/agents/devflow/pr-comments.md +0 -285
- package/src/claude/agents/devflow/project-state.md +0 -419
- package/src/claude/agents/devflow/pull-request.md +0 -493
- package/src/claude/agents/devflow/release.md +0 -1137
- package/src/claude/agents/devflow/tech-debt.md +0 -338
- package/src/claude/commands/devflow/brainstorm.md +0 -68
- package/src/claude/commands/devflow/breakdown.md +0 -125
- package/src/claude/commands/devflow/catch-up.md +0 -29
- package/src/claude/commands/devflow/code-review.md +0 -237
- package/src/claude/commands/devflow/commit.md +0 -17
- package/src/claude/commands/devflow/debug.md +0 -56
- package/src/claude/commands/devflow/design.md +0 -82
- package/src/claude/commands/devflow/devlog.md +0 -408
- package/src/claude/commands/devflow/get-issue.md +0 -16
- package/src/claude/commands/devflow/implement.md +0 -100
- package/src/claude/commands/devflow/plan.md +0 -223
- package/src/claude/commands/devflow/pull-request.md +0 -20
- package/src/claude/commands/devflow/release.md +0 -251
- package/src/claude/commands/devflow/resolve-comments.md +0 -583
- package/src/claude/scripts/statusline.sh +0 -47
- package/src/claude/settings.json +0 -6
- package/src/claude/skills/devflow/code-smell/SKILL.md +0 -428
- package/src/claude/skills/devflow/debug/SKILL.md +0 -119
- package/src/claude/skills/devflow/error-handling/SKILL.md +0 -597
- package/src/claude/skills/devflow/input-validation/SKILL.md +0 -514
- package/src/claude/skills/devflow/pattern-check/SKILL.md +0 -238
- package/src/claude/skills/devflow/research/SKILL.md +0 -138
- package/src/claude/skills/devflow/test-design/SKILL.md +0 -384
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# Performance Violation Examples
|
|
2
|
+
|
|
3
|
+
Extended violation patterns for performance reviews. Reference from main SKILL.md.
|
|
4
|
+
|
|
5
|
+
## Algorithmic Violations
|
|
6
|
+
|
|
7
|
+
### N+1 Query Variants
|
|
8
|
+
|
|
9
|
+
**ORM Eager Loading Missing**
|
|
10
|
+
```typescript
|
|
11
|
+
// VIOLATION: Lazy loading triggers N queries
|
|
12
|
+
const posts = await Post.findAll();
|
|
13
|
+
for (const post of posts) {
|
|
14
|
+
console.log(post.author.name); // N additional queries
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**GraphQL Resolver N+1**
|
|
19
|
+
```typescript
|
|
20
|
+
// VIOLATION: Resolver called per item
|
|
21
|
+
const resolvers = {
|
|
22
|
+
Post: {
|
|
23
|
+
author: async (post) => {
|
|
24
|
+
return db.users.findById(post.authorId); // N queries
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Nested Loop Queries**
|
|
31
|
+
```typescript
|
|
32
|
+
// VIOLATION: Query inside nested loop
|
|
33
|
+
for (const category of categories) {
|
|
34
|
+
for (const product of category.products) {
|
|
35
|
+
const reviews = await db.reviews.findByProductId(product.id); // N*M queries
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### O(n^2) or Worse Patterns
|
|
41
|
+
|
|
42
|
+
**Array.includes in Loop**
|
|
43
|
+
```typescript
|
|
44
|
+
// VIOLATION: O(n^2) - includes is O(n)
|
|
45
|
+
function removeDuplicates(items: Item[]) {
|
|
46
|
+
const unique: Item[] = [];
|
|
47
|
+
for (const item of items) {
|
|
48
|
+
if (!unique.some(u => u.id === item.id)) { // O(n) check each time
|
|
49
|
+
unique.push(item);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return unique;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Nested Array Methods**
|
|
57
|
+
```typescript
|
|
58
|
+
// VIOLATION: O(n*m) - filter inside map
|
|
59
|
+
function matchItems(list1: Item[], list2: Item[]) {
|
|
60
|
+
return list1.map(item => ({
|
|
61
|
+
...item,
|
|
62
|
+
matches: list2.filter(i => i.category === item.category) // O(m) per item
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**String Concatenation in Loop**
|
|
68
|
+
```typescript
|
|
69
|
+
// VIOLATION: O(n^2) string copies
|
|
70
|
+
function buildCsv(rows: string[][]): string {
|
|
71
|
+
let csv = '';
|
|
72
|
+
for (const row of rows) {
|
|
73
|
+
csv += row.join(',') + '\n'; // Creates new string each time
|
|
74
|
+
}
|
|
75
|
+
return csv;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Inefficient Data Structure Usage
|
|
80
|
+
|
|
81
|
+
**Object.keys/values/entries in Hot Path**
|
|
82
|
+
```typescript
|
|
83
|
+
// VIOLATION: Creates new array on each call
|
|
84
|
+
function findInObject(obj: Record<string, Item>, predicate: (item: Item) => boolean) {
|
|
85
|
+
for (const key of Object.keys(obj)) { // Allocates array
|
|
86
|
+
if (predicate(obj[key])) {
|
|
87
|
+
return obj[key];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Array as Queue/Stack**
|
|
94
|
+
```typescript
|
|
95
|
+
// VIOLATION: shift() is O(n)
|
|
96
|
+
class Queue<T> {
|
|
97
|
+
private items: T[] = [];
|
|
98
|
+
|
|
99
|
+
dequeue(): T | undefined {
|
|
100
|
+
return this.items.shift(); // O(n) - reindexes entire array
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Database Violations
|
|
108
|
+
|
|
109
|
+
### Missing Index Patterns
|
|
110
|
+
|
|
111
|
+
**Unindexed Foreign Key**
|
|
112
|
+
```sql
|
|
113
|
+
-- VIOLATION: Joins without index
|
|
114
|
+
SELECT * FROM orders o
|
|
115
|
+
JOIN order_items oi ON o.id = oi.order_id -- order_id likely unindexed
|
|
116
|
+
WHERE o.customer_id = 123;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Unindexed Filter Column**
|
|
120
|
+
```typescript
|
|
121
|
+
// VIOLATION: Filters on unindexed column
|
|
122
|
+
const activeUsers = await db.query(
|
|
123
|
+
'SELECT * FROM users WHERE last_login > ?', // last_login probably unindexed
|
|
124
|
+
[thirtyDaysAgo]
|
|
125
|
+
);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Composite Index Order Wrong**
|
|
129
|
+
```sql
|
|
130
|
+
-- Index exists: (customer_id, status)
|
|
131
|
+
-- VIOLATION: Query doesn't use index efficiently
|
|
132
|
+
SELECT * FROM orders WHERE status = 'pending'; -- Can't use composite index
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Inefficient Queries
|
|
136
|
+
|
|
137
|
+
**LIKE with Leading Wildcard**
|
|
138
|
+
```typescript
|
|
139
|
+
// VIOLATION: Can't use index
|
|
140
|
+
const results = await db.query(
|
|
141
|
+
'SELECT * FROM products WHERE name LIKE ?',
|
|
142
|
+
['%laptop%'] // Leading % prevents index usage
|
|
143
|
+
);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**OR Instead of IN**
|
|
147
|
+
```typescript
|
|
148
|
+
// VIOLATION: OR conditions often slower
|
|
149
|
+
const users = await db.query(
|
|
150
|
+
'SELECT * FROM users WHERE status = ? OR status = ? OR status = ?',
|
|
151
|
+
['active', 'pending', 'trial']
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
// Better: Use IN clause
|
|
155
|
+
const users = await db.query(
|
|
156
|
+
'SELECT * FROM users WHERE status IN (?, ?, ?)',
|
|
157
|
+
['active', 'pending', 'trial']
|
|
158
|
+
);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Sorting Without Index**
|
|
162
|
+
```typescript
|
|
163
|
+
// VIOLATION: ORDER BY on unindexed column causes filesort
|
|
164
|
+
const recent = await db.query(
|
|
165
|
+
'SELECT * FROM logs ORDER BY created_at DESC LIMIT 100' // No index on created_at
|
|
166
|
+
);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Memory Violations
|
|
172
|
+
|
|
173
|
+
### Memory Leak Patterns
|
|
174
|
+
|
|
175
|
+
**Closure Retaining Large Object**
|
|
176
|
+
```typescript
|
|
177
|
+
// VIOLATION: Closure keeps entire large object alive
|
|
178
|
+
function processLargeData(data: LargeObject) {
|
|
179
|
+
return () => {
|
|
180
|
+
console.log(data.id); // Only needs id, but retains entire data object
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Timer Without Cleanup**
|
|
186
|
+
```typescript
|
|
187
|
+
// VIOLATION: Interval never cleared
|
|
188
|
+
class Poller {
|
|
189
|
+
start() {
|
|
190
|
+
setInterval(() => this.poll(), 1000); // Runs forever
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Observable Without Unsubscribe**
|
|
196
|
+
```typescript
|
|
197
|
+
// VIOLATION: Subscription never cleaned up
|
|
198
|
+
class Component {
|
|
199
|
+
init() {
|
|
200
|
+
eventBus.subscribe('update', this.handleUpdate); // Memory leak
|
|
201
|
+
}
|
|
202
|
+
// Missing cleanup method
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Large Allocation Patterns
|
|
207
|
+
|
|
208
|
+
**Spreading in Reduce**
|
|
209
|
+
```typescript
|
|
210
|
+
// VIOLATION: Creates new object on each iteration
|
|
211
|
+
const merged = items.reduce((acc, item) => ({
|
|
212
|
+
...acc, // Copies entire accumulator each time
|
|
213
|
+
[item.id]: item
|
|
214
|
+
}), {});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Array.concat in Loop**
|
|
218
|
+
```typescript
|
|
219
|
+
// VIOLATION: Creates new array each iteration
|
|
220
|
+
let all: Item[] = [];
|
|
221
|
+
for (const batch of batches) {
|
|
222
|
+
all = all.concat(batch); // O(n^2) total allocations
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**JSON Clone in Hot Path**
|
|
227
|
+
```typescript
|
|
228
|
+
// VIOLATION: Full serialization/parsing
|
|
229
|
+
function processItem(item: Item) {
|
|
230
|
+
const copy = JSON.parse(JSON.stringify(item)); // Expensive!
|
|
231
|
+
// ... modify copy
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## I/O Violations
|
|
238
|
+
|
|
239
|
+
### Blocking Operations
|
|
240
|
+
|
|
241
|
+
**Sync File Operations in Request Handler**
|
|
242
|
+
```typescript
|
|
243
|
+
// VIOLATION: Blocks event loop
|
|
244
|
+
app.get('/config', (req, res) => {
|
|
245
|
+
const config = fs.readFileSync('./config.json'); // Blocks!
|
|
246
|
+
res.json(JSON.parse(config));
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Sync Crypto Operations**
|
|
251
|
+
```typescript
|
|
252
|
+
// VIOLATION: CPU-intensive sync operation
|
|
253
|
+
function hashPassword(password: string): string {
|
|
254
|
+
return crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha512'); // Blocks!
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Sequential vs Parallel
|
|
259
|
+
|
|
260
|
+
**await in forEach (No Parallelism)**
|
|
261
|
+
```typescript
|
|
262
|
+
// VIOLATION: forEach doesn't wait, unpredictable behavior
|
|
263
|
+
ids.forEach(async (id) => {
|
|
264
|
+
await processItem(id); // Fire and forget!
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Sequential Processing When Order Doesn't Matter**
|
|
269
|
+
```typescript
|
|
270
|
+
// VIOLATION: Could be parallel
|
|
271
|
+
async function validateAll(items: Item[]) {
|
|
272
|
+
const results = [];
|
|
273
|
+
for (const item of items) {
|
|
274
|
+
results.push(await validate(item)); // Sequential but independent
|
|
275
|
+
}
|
|
276
|
+
return results;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Redundant Operations
|
|
281
|
+
|
|
282
|
+
**Same Data Fetched Multiple Times**
|
|
283
|
+
```typescript
|
|
284
|
+
// VIOLATION: Duplicate API calls
|
|
285
|
+
async function buildReport(userId: string) {
|
|
286
|
+
const user = await getUser(userId);
|
|
287
|
+
const profile = await getUserProfile(userId); // Probably same data
|
|
288
|
+
const permissions = await getUserPermissions(userId); // Another call
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Cache Miss on Every Request**
|
|
293
|
+
```typescript
|
|
294
|
+
// VIOLATION: No caching strategy
|
|
295
|
+
async function getConfig() {
|
|
296
|
+
return await fetchFromRemote('/config'); // Network call every time
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Frontend Violations
|
|
303
|
+
|
|
304
|
+
### Re-render Patterns
|
|
305
|
+
|
|
306
|
+
**Inline Object/Array in JSX**
|
|
307
|
+
```tsx
|
|
308
|
+
// VIOLATION: New reference every render
|
|
309
|
+
<Component
|
|
310
|
+
options={{ show: true, animate: false }} // New object each render
|
|
311
|
+
items={[1, 2, 3]} // New array each render
|
|
312
|
+
/>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Inline Arrow in JSX**
|
|
316
|
+
```tsx
|
|
317
|
+
// VIOLATION: New function every render
|
|
318
|
+
<Button onClick={() => handleClick(item.id)} /> // New function each render
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Missing Key or Index as Key**
|
|
322
|
+
```tsx
|
|
323
|
+
// VIOLATION: Index as key breaks reconciliation
|
|
324
|
+
{items.map((item, index) => (
|
|
325
|
+
<Item key={index} {...item} /> // Index key causes issues on reorder
|
|
326
|
+
))}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Missing Optimization
|
|
330
|
+
|
|
331
|
+
**Expensive Computation Every Render**
|
|
332
|
+
```tsx
|
|
333
|
+
// VIOLATION: Recalculates on every render
|
|
334
|
+
function Dashboard({ data }) {
|
|
335
|
+
const stats = computeExpensiveStats(data); // Runs every render
|
|
336
|
+
return <Stats data={stats} />;
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Unthrottled Event Handler**
|
|
341
|
+
```tsx
|
|
342
|
+
// VIOLATION: Fires on every scroll pixel
|
|
343
|
+
window.addEventListener('scroll', () => {
|
|
344
|
+
updateParallax(); // 60+ calls per second
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Large Component Tree Without Code Splitting**
|
|
349
|
+
```tsx
|
|
350
|
+
// VIOLATION: Loads everything upfront
|
|
351
|
+
import HugeChartLibrary from 'huge-chart-lib';
|
|
352
|
+
import RarelyUsedFeature from './RarelyUsedFeature';
|
|
353
|
+
// All loaded even if not used
|
|
354
|
+
```
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react
|
|
3
|
+
description: This skill should be used when the user works with React components (.tsx/.jsx), asks about "hooks", "state management", "context providers", "memo optimization", "useEffect", or discusses component composition and rendering performance. Provides patterns for hooks, state, effects, memoization, and React-specific architecture.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
allowed-tools: Read, Grep, Glob
|
|
6
|
+
activation:
|
|
7
|
+
file-patterns:
|
|
8
|
+
- "**/*.tsx"
|
|
9
|
+
- "**/*.jsx"
|
|
10
|
+
exclude:
|
|
11
|
+
- "node_modules/**"
|
|
12
|
+
- "**/*.test.*"
|
|
13
|
+
- "**/*.spec.*"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# React Patterns
|
|
17
|
+
|
|
18
|
+
Reference for React-specific patterns, component design, hooks, and performance optimization.
|
|
19
|
+
|
|
20
|
+
## Iron Law
|
|
21
|
+
|
|
22
|
+
> **COMPOSITION OVER PROPS**
|
|
23
|
+
>
|
|
24
|
+
> Use children and compound components, not prop drilling. If a component has >5 props,
|
|
25
|
+
> it's doing too much. Split it. If you're passing data through 3+ levels, use context
|
|
26
|
+
> or composition. Props are for configuration, not data plumbing.
|
|
27
|
+
|
|
28
|
+
## When This Skill Activates
|
|
29
|
+
|
|
30
|
+
- Working with React codebases
|
|
31
|
+
- Creating components and hooks
|
|
32
|
+
- Managing state and side effects
|
|
33
|
+
- Optimizing render performance
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Component Patterns
|
|
38
|
+
|
|
39
|
+
### Functional Component Structure
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
export function UserCard({ user, className }: UserCardProps) {
|
|
43
|
+
const [isExpanded, setIsExpanded] = useState(false); // 1. Hooks first
|
|
44
|
+
const displayName = user.firstName + ' ' + user.lastName; // 2. Derived state
|
|
45
|
+
const handleToggle = () => setIsExpanded((prev) => !prev); // 3. Handlers
|
|
46
|
+
return ( // 4. Render
|
|
47
|
+
<div className={cn('user-card', className)}>
|
|
48
|
+
<h3>{displayName}</h3>
|
|
49
|
+
{isExpanded && <UserDetails user={user} />}
|
|
50
|
+
<button onClick={handleToggle}>{isExpanded ? 'Collapse' : 'Expand'}</button>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Composition Over Props
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
function Card({ children }: { children: React.ReactNode }) {
|
|
60
|
+
return <div className="card">{children}</div>;
|
|
61
|
+
}
|
|
62
|
+
Card.Header = ({ children }) => <div className="card-header">{children}</div>;
|
|
63
|
+
Card.Body = ({ children }) => <div className="card-body">{children}</div>;
|
|
64
|
+
|
|
65
|
+
// Usage - flexible, not rigid props
|
|
66
|
+
<Card>
|
|
67
|
+
<Card.Header><h2>Title</h2></Card.Header>
|
|
68
|
+
<Card.Body><p>Content</p></Card.Body>
|
|
69
|
+
</Card>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Hook Patterns
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
function useLocalStorage<T>(key: string, initialValue: T) {
|
|
78
|
+
const [value, setValue] = useState<T>(() => {
|
|
79
|
+
const stored = localStorage.getItem(key);
|
|
80
|
+
return stored ? JSON.parse(stored) : initialValue;
|
|
81
|
+
});
|
|
82
|
+
useEffect(() => localStorage.setItem(key, JSON.stringify(value)), [key, value]);
|
|
83
|
+
return [value, setValue] as const;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## State Management
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
const AuthContext = createContext<AuthContextValue | null>(null);
|
|
93
|
+
|
|
94
|
+
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
|
95
|
+
const [user, setUser] = useState<User | null>(null);
|
|
96
|
+
const login = async (creds: Credentials) => setUser(await authApi.login(creds));
|
|
97
|
+
const logout = () => { authApi.logout(); setUser(null); };
|
|
98
|
+
return <AuthContext.Provider value={{ user, login, logout }}>{children}</AuthContext.Provider>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function useAuth() {
|
|
102
|
+
const ctx = useContext(AuthContext);
|
|
103
|
+
if (!ctx) throw new Error('useAuth must be used within AuthProvider');
|
|
104
|
+
return ctx;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Performance
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
function UserList({ users, filter }: { users: User[]; filter: string }) {
|
|
114
|
+
const filtered = useMemo(() => users.filter((u) => u.name.includes(filter)), [users, filter]);
|
|
115
|
+
const onClick = useCallback(() => console.log('Clicked'), []);
|
|
116
|
+
return <ul>{filtered.map((u) => <MemoItem key={u.id} user={u} onClick={onClick} />)}</ul>;
|
|
117
|
+
}
|
|
118
|
+
const MemoItem = memo(({ user }: { user: User }) => <li>{user.name}</li>);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Async Parallelization
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
// CORRECT: Independent fetches run in parallel
|
|
127
|
+
async function loadDashboard(userId: string) {
|
|
128
|
+
const [user, orders, preferences] = await Promise.all([
|
|
129
|
+
fetchUser(userId),
|
|
130
|
+
fetchOrders(userId),
|
|
131
|
+
fetchPreferences(userId),
|
|
132
|
+
]);
|
|
133
|
+
return { user, orders, preferences };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// VIOLATION: Sequential fetches (3x slower)
|
|
137
|
+
async function loadDashboardSlow(userId: string) {
|
|
138
|
+
const user = await fetchUser(userId);
|
|
139
|
+
const orders = await fetchOrders(userId);
|
|
140
|
+
const preferences = await fetchPreferences(userId);
|
|
141
|
+
return { user, orders, preferences };
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Bundle Size
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
// CORRECT: Direct imports (tree-shakable)
|
|
151
|
+
import { Button } from '@/components/Button';
|
|
152
|
+
import { Card } from '@/components/Card';
|
|
153
|
+
|
|
154
|
+
// VIOLATION: Barrel imports (imports entire library)
|
|
155
|
+
import { Button, Card } from '@/components';
|
|
156
|
+
|
|
157
|
+
// CORRECT: Dynamic import for heavy components
|
|
158
|
+
const Chart = lazy(() => import('./Chart'));
|
|
159
|
+
const Editor = lazy(() => import('./Editor'));
|
|
160
|
+
|
|
161
|
+
function Dashboard() {
|
|
162
|
+
return (
|
|
163
|
+
<Suspense fallback={<Skeleton />}>
|
|
164
|
+
{showChart && <Chart data={data} />}
|
|
165
|
+
</Suspense>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Re-render Optimization
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
// CORRECT: Primitive deps (stable references)
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
fetchData(userId, isActive);
|
|
178
|
+
}, [userId, isActive]); // primitives don't cause unnecessary runs
|
|
179
|
+
|
|
180
|
+
// VIOLATION: Object/array deps (new reference every render)
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
fetchData(options);
|
|
183
|
+
}, [options]); // { page: 1 } !== { page: 1 }
|
|
184
|
+
|
|
185
|
+
// CORRECT: Stable callback with useCallback
|
|
186
|
+
const handleClick = useCallback((id: string) => {
|
|
187
|
+
setSelected(id);
|
|
188
|
+
}, []); // no deps = stable reference
|
|
189
|
+
|
|
190
|
+
// VIOLATION: Inline function (new reference every render)
|
|
191
|
+
<List onItemClick={(id) => setSelected(id)} />
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Image Optimization
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
// CORRECT: Optimized image with all attributes
|
|
200
|
+
<img
|
|
201
|
+
src={url}
|
|
202
|
+
alt={description}
|
|
203
|
+
width={400}
|
|
204
|
+
height={300}
|
|
205
|
+
loading="lazy"
|
|
206
|
+
decoding="async"
|
|
207
|
+
style={{ aspectRatio: '4/3' }}
|
|
208
|
+
/>
|
|
209
|
+
|
|
210
|
+
// VIOLATION: Unoptimized image
|
|
211
|
+
<img src={url} /> // No dimensions, no lazy loading, layout shift
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Data Structure Performance
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
// CORRECT: Set for O(1) membership checks
|
|
220
|
+
const selectedIds = new Set(selected);
|
|
221
|
+
const isSelected = (id: string) => selectedIds.has(id);
|
|
222
|
+
|
|
223
|
+
// VIOLATION: Array.includes is O(n)
|
|
224
|
+
const isSelected = (id: string) => selected.includes(id);
|
|
225
|
+
|
|
226
|
+
// CORRECT: Map for key-value lookups
|
|
227
|
+
const usersById = new Map(users.map(u => [u.id, u]));
|
|
228
|
+
const getUser = (id: string) => usersById.get(id);
|
|
229
|
+
|
|
230
|
+
// VIOLATION: Array.find is O(n)
|
|
231
|
+
const getUser = (id: string) => users.find(u => u.id === id);
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Anti-Patterns
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
// BAD: Derived state in useState | GOOD: useMemo
|
|
240
|
+
const filtered = useMemo(() => items.filter(i => i.active), [items]);
|
|
241
|
+
|
|
242
|
+
// BAD: Missing dependency | GOOD: Include all deps
|
|
243
|
+
useEffect(() => { fetchData(userId); }, [userId]);
|
|
244
|
+
|
|
245
|
+
// BAD: State update in render | GOOD: Use effect
|
|
246
|
+
useEffect(() => { setState(value); }, [value]);
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Extended References
|
|
252
|
+
|
|
253
|
+
- `references/patterns.md` - Render props, reducers, virtualization, lazy loading
|
|
254
|
+
- `references/hooks.md` - useQuery, useDebouncedValue, usePrevious, useClickOutside
|
|
255
|
+
- `references/forms.md` - Controlled forms, validation hooks, multi-step forms
|
|
256
|
+
- `references/error-handling.md` - Error boundaries, async error handling
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Checklist
|
|
261
|
+
|
|
262
|
+
- [ ] Hooks at top level only
|
|
263
|
+
- [ ] All useEffect deps included
|
|
264
|
+
- [ ] useCallback for handlers passed to children
|
|
265
|
+
- [ ] useMemo for expensive computations
|
|
266
|
+
- [ ] Context at appropriate level
|
|
267
|
+
- [ ] Error boundaries around risky components
|
|
268
|
+
- [ ] Keys on list items (not index)
|
|
269
|
+
- [ ] Loading/error states handled
|
|
270
|
+
- [ ] Accessibility (aria-*, role)
|
|
271
|
+
- [ ] Independent fetches parallelized with Promise.all
|
|
272
|
+
- [ ] No barrel imports (direct imports for tree-shaking)
|
|
273
|
+
- [ ] Large components lazy-loaded
|
|
274
|
+
- [ ] Object/array deps avoided in useEffect (use primitives)
|
|
275
|
+
- [ ] Set/Map used for lookups instead of Array.includes/find
|
|
276
|
+
- [ ] Images have dimensions, lazy loading, and aspect-ratio
|