devflow-kit 0.9.0 → 1.1.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 +197 -29
- package/LICENSE +1 -1
- package/README.md +185 -309
- package/dist/cli.js +7 -1
- package/dist/commands/ambient.d.ts +18 -0
- package/dist/commands/ambient.js +136 -0
- package/dist/commands/init.d.ts +23 -0
- package/dist/commands/init.js +393 -571
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.js +20 -0
- package/dist/commands/memory.d.ts +22 -0
- package/dist/commands/memory.js +175 -0
- package/dist/commands/uninstall.d.ts +10 -0
- package/dist/commands/uninstall.js +418 -78
- package/dist/plugins.d.ts +46 -0
- package/dist/plugins.js +169 -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 +80 -0
- package/dist/utils/post-install.js +508 -0
- package/dist/utils/safe-delete-install.d.ts +29 -0
- package/dist/utils/safe-delete-install.js +191 -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-ambient/.claude-plugin/plugin.json +7 -0
- package/plugins/devflow-ambient/README.md +49 -0
- package/plugins/devflow-ambient/commands/ambient.md +110 -0
- package/plugins/devflow-ambient/skills/ambient-router/SKILL.md +89 -0
- package/plugins/devflow-ambient/skills/ambient-router/references/skill-catalog.md +64 -0
- 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 +28 -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 +138 -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-driven-development/SKILL.md +139 -0
- package/plugins/devflow-core-skills/skills/test-driven-development/references/rationalization-prevention.md +111 -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/ambient-prompt.sh +48 -0
- package/scripts/hooks/background-memory-update.sh +208 -0
- package/scripts/hooks/ensure-memory-gitignore.sh +17 -0
- package/scripts/hooks/pre-compact-memory.sh +87 -0
- package/scripts/hooks/session-start-memory.sh +126 -0
- package/scripts/hooks/stop-update-memory.sh +85 -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/ambient-router/SKILL.md +89 -0
- package/shared/skills/ambient-router/references/skill-catalog.md +64 -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 +138 -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-driven-development/SKILL.md +139 -0
- package/shared/skills/test-driven-development/references/rationalization-prevention.md +111 -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 +160 -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,575 @@
|
|
|
1
|
+
# Architecture Violation Examples
|
|
2
|
+
|
|
3
|
+
Extended violation patterns for architecture reviews. Reference from main SKILL.md.
|
|
4
|
+
|
|
5
|
+
## SOLID Violations
|
|
6
|
+
|
|
7
|
+
### Single Responsibility Principle (SRP)
|
|
8
|
+
|
|
9
|
+
**Monolithic Controller**
|
|
10
|
+
```typescript
|
|
11
|
+
// VIOLATION: Controller handles HTTP, validation, business logic, DB, email, logging
|
|
12
|
+
class UserController {
|
|
13
|
+
async createUser(req, res) {
|
|
14
|
+
// Logging
|
|
15
|
+
console.log(`Creating user: ${req.body.email}`);
|
|
16
|
+
|
|
17
|
+
// Validation
|
|
18
|
+
if (!req.body.email.includes('@')) {
|
|
19
|
+
return res.status(400).json({ error: 'Invalid email' });
|
|
20
|
+
}
|
|
21
|
+
if (req.body.password.length < 8) {
|
|
22
|
+
return res.status(400).json({ error: 'Password too short' });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Business logic
|
|
26
|
+
const existingUser = await db.users.findOne({ email: req.body.email });
|
|
27
|
+
if (existingUser) {
|
|
28
|
+
return res.status(409).json({ error: 'User exists' });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Password hashing
|
|
32
|
+
const hash = await bcrypt.hash(req.body.password, 12);
|
|
33
|
+
|
|
34
|
+
// Database operation
|
|
35
|
+
const user = await db.users.create({
|
|
36
|
+
email: req.body.email,
|
|
37
|
+
password: hash,
|
|
38
|
+
createdAt: new Date()
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Email sending
|
|
42
|
+
await sendEmail(user.email, 'Welcome!', welcomeTemplate(user));
|
|
43
|
+
|
|
44
|
+
// Analytics
|
|
45
|
+
await analytics.track('user_created', { userId: user.id });
|
|
46
|
+
|
|
47
|
+
// Response formatting
|
|
48
|
+
res.json({
|
|
49
|
+
id: user.id,
|
|
50
|
+
email: user.email,
|
|
51
|
+
createdAt: user.createdAt
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Reasons to Change Analysis**
|
|
58
|
+
|
|
59
|
+
| Responsibility | Reason to Change |
|
|
60
|
+
|----------------|------------------|
|
|
61
|
+
| HTTP handling | API contract changes |
|
|
62
|
+
| Validation | Business rules change |
|
|
63
|
+
| Password hashing | Security requirements change |
|
|
64
|
+
| Database access | Schema or ORM changes |
|
|
65
|
+
| Email sending | Email provider changes |
|
|
66
|
+
| Analytics | Tracking requirements change |
|
|
67
|
+
| Logging | Logging format changes |
|
|
68
|
+
|
|
69
|
+
Each reason = separate class.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### Open/Closed Principle (OCP)
|
|
74
|
+
|
|
75
|
+
**Payment Processing Without Strategy**
|
|
76
|
+
```typescript
|
|
77
|
+
// VIOLATION: Every new payment method requires modifying existing code
|
|
78
|
+
class PaymentProcessor {
|
|
79
|
+
process(method: string, amount: number) {
|
|
80
|
+
if (method === 'credit_card') {
|
|
81
|
+
return this.processCreditCard(amount);
|
|
82
|
+
} else if (method === 'paypal') {
|
|
83
|
+
return this.processPayPal(amount);
|
|
84
|
+
} else if (method === 'stripe') {
|
|
85
|
+
// Stripe logic - added later, modified existing class
|
|
86
|
+
return this.processStripe(amount);
|
|
87
|
+
} else if (method === 'apple_pay') {
|
|
88
|
+
// Apple Pay - yet another modification
|
|
89
|
+
return this.processApplePay(amount);
|
|
90
|
+
}
|
|
91
|
+
throw new Error('Unknown payment method');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private processCreditCard(amount: number) { /* ... */ }
|
|
95
|
+
private processPayPal(amount: number) { /* ... */ }
|
|
96
|
+
private processStripe(amount: number) { /* ... */ }
|
|
97
|
+
private processApplePay(amount: number) { /* ... */ }
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Liskov Substitution Principle (LSP)
|
|
104
|
+
|
|
105
|
+
**Subclass Changing Behavior**
|
|
106
|
+
```typescript
|
|
107
|
+
// VIOLATION: Subclass changes behavior unexpectedly
|
|
108
|
+
class FileStorage {
|
|
109
|
+
read(path: string): string {
|
|
110
|
+
return fs.readFileSync(path, 'utf8');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
write(path: string, content: string): void {
|
|
114
|
+
fs.writeFileSync(path, content);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
delete(path: string): void {
|
|
118
|
+
fs.unlinkSync(path);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class ReadOnlyStorage extends FileStorage {
|
|
123
|
+
write(path: string, content: string): void {
|
|
124
|
+
throw new Error('Cannot write to read-only storage'); // Breaks LSP!
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
delete(path: string): void {
|
|
128
|
+
throw new Error('Cannot delete from read-only storage'); // Breaks LSP!
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Using the subclass breaks code expecting FileStorage behavior
|
|
133
|
+
function backup(storage: FileStorage, data: string) {
|
|
134
|
+
storage.write('/backup/data.txt', data); // Throws if ReadOnlyStorage!
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### Interface Segregation Principle (ISP)
|
|
141
|
+
|
|
142
|
+
**Fat Interface**
|
|
143
|
+
```typescript
|
|
144
|
+
// VIOLATION: Fat interface forces unnecessary implementations
|
|
145
|
+
interface DocumentHandler {
|
|
146
|
+
open(path: string): Document;
|
|
147
|
+
save(doc: Document): void;
|
|
148
|
+
print(doc: Document): void;
|
|
149
|
+
email(doc: Document, to: string): void;
|
|
150
|
+
fax(doc: Document, number: string): void;
|
|
151
|
+
encrypt(doc: Document): Document;
|
|
152
|
+
compress(doc: Document): Buffer;
|
|
153
|
+
watermark(doc: Document, text: string): Document;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// PDF handler doesn't need fax capability
|
|
157
|
+
class PdfHandler implements DocumentHandler {
|
|
158
|
+
open(path: string) { /* OK */ }
|
|
159
|
+
save(doc: Document) { /* OK */ }
|
|
160
|
+
print(doc: Document) { /* OK */ }
|
|
161
|
+
email(doc: Document, to: string) { /* OK */ }
|
|
162
|
+
fax(doc: Document, number: string) {
|
|
163
|
+
throw new Error('PDF handler does not support fax'); // Forced implementation
|
|
164
|
+
}
|
|
165
|
+
encrypt(doc: Document) { /* OK */ }
|
|
166
|
+
compress(doc: Document) { /* OK */ }
|
|
167
|
+
watermark(doc: Document, text: string) { /* OK */ }
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### Dependency Inversion Principle (DIP)
|
|
174
|
+
|
|
175
|
+
**High-Level Module Depends on Low-Level**
|
|
176
|
+
```typescript
|
|
177
|
+
// VIOLATION: High-level module depends on low-level implementations
|
|
178
|
+
class NotificationService {
|
|
179
|
+
private twilioClient = new TwilioClient(process.env.TWILIO_KEY);
|
|
180
|
+
private sendgridClient = new SendGridClient(process.env.SENDGRID_KEY);
|
|
181
|
+
private slackClient = new SlackClient(process.env.SLACK_TOKEN);
|
|
182
|
+
|
|
183
|
+
async notifyUser(userId: string, message: string) {
|
|
184
|
+
const user = await db.users.findById(userId);
|
|
185
|
+
|
|
186
|
+
if (user.preferences.sms) {
|
|
187
|
+
await this.twilioClient.sendSMS(user.phone, message);
|
|
188
|
+
}
|
|
189
|
+
if (user.preferences.email) {
|
|
190
|
+
await this.sendgridClient.sendEmail(user.email, 'Notification', message);
|
|
191
|
+
}
|
|
192
|
+
if (user.preferences.slack) {
|
|
193
|
+
await this.slackClient.postMessage(user.slackId, message);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Problems:
|
|
199
|
+
// 1. Can't test without real API keys
|
|
200
|
+
// 2. Adding new channel requires modifying this class
|
|
201
|
+
// 3. Tightly coupled to specific providers
|
|
202
|
+
// 4. Can't swap providers easily
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Coupling Violations
|
|
208
|
+
|
|
209
|
+
### Circular Dependencies
|
|
210
|
+
|
|
211
|
+
**User-Order Cycle**
|
|
212
|
+
```typescript
|
|
213
|
+
// VIOLATION: Services depend on each other creating a cycle
|
|
214
|
+
// user.service.ts
|
|
215
|
+
import { OrderService } from './order.service';
|
|
216
|
+
|
|
217
|
+
class UserService {
|
|
218
|
+
constructor(private orderService: OrderService) {}
|
|
219
|
+
|
|
220
|
+
async deleteUser(userId: string) {
|
|
221
|
+
// Need to cancel all user's orders first
|
|
222
|
+
await this.orderService.cancelAllUserOrders(userId);
|
|
223
|
+
await this.repository.delete(userId);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async getUserWithOrderTotal(userId: string) {
|
|
227
|
+
const user = await this.repository.findById(userId);
|
|
228
|
+
user.totalSpent = await this.orderService.calculateUserTotal(userId);
|
|
229
|
+
return user;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// order.service.ts
|
|
234
|
+
import { UserService } from './user.service';
|
|
235
|
+
|
|
236
|
+
class OrderService {
|
|
237
|
+
constructor(private userService: UserService) {}
|
|
238
|
+
|
|
239
|
+
async createOrder(userId: string, items: Item[]) {
|
|
240
|
+
// Need to check user's credit limit
|
|
241
|
+
const user = await this.userService.getUser(userId);
|
|
242
|
+
if (user.creditLimit < this.calculateTotal(items)) {
|
|
243
|
+
throw new Error('Credit limit exceeded');
|
|
244
|
+
}
|
|
245
|
+
return this.repository.create({ userId, items });
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async cancelAllUserOrders(userId: string) {
|
|
249
|
+
// Check if user exists first
|
|
250
|
+
const user = await this.userService.getUser(userId);
|
|
251
|
+
if (!user) throw new Error('User not found');
|
|
252
|
+
|
|
253
|
+
await this.repository.cancelByUserId(userId);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// PROBLEM: Cannot instantiate either without the other
|
|
258
|
+
// const userService = new UserService(???); // Need OrderService
|
|
259
|
+
// const orderService = new OrderService(???); // Need UserService
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Detection Pattern**
|
|
263
|
+
```bash
|
|
264
|
+
# Find potential circular dependencies
|
|
265
|
+
grep -rn "import.*from.*service" --include="*service*.ts" | \
|
|
266
|
+
awk -F: '{print $1, $3}' | sort | uniq
|
|
267
|
+
|
|
268
|
+
# Check with tooling
|
|
269
|
+
npx madge --circular src/
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
### Feature Envy
|
|
275
|
+
|
|
276
|
+
**Order Processing Reaching Into Internals**
|
|
277
|
+
```typescript
|
|
278
|
+
// VIOLATION: OrderProcessor reaches deeply into Order internals
|
|
279
|
+
class OrderProcessor {
|
|
280
|
+
async process(order: Order) {
|
|
281
|
+
// Reaching into customer details
|
|
282
|
+
const customerName = order.customer.profile.name;
|
|
283
|
+
const customerEmail = order.customer.profile.contact.email;
|
|
284
|
+
const customerPhone = order.customer.profile.contact.phone;
|
|
285
|
+
const shippingAddress = order.customer.addresses.find(a => a.type === 'shipping');
|
|
286
|
+
const billingAddress = order.customer.addresses.find(a => a.type === 'billing');
|
|
287
|
+
|
|
288
|
+
// Reaching into order items
|
|
289
|
+
let subtotal = 0;
|
|
290
|
+
for (const item of order.items) {
|
|
291
|
+
const basePrice = item.product.pricing.basePrice;
|
|
292
|
+
const discount = item.product.pricing.activePromotions
|
|
293
|
+
.filter(p => p.validUntil > new Date())
|
|
294
|
+
.reduce((sum, p) => sum + p.discountPercent, 0);
|
|
295
|
+
const quantity = item.quantity;
|
|
296
|
+
const itemTotal = basePrice * quantity * (1 - discount / 100);
|
|
297
|
+
subtotal += itemTotal;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Reaching into shipping details
|
|
301
|
+
const weight = order.items.reduce((sum, i) => sum + i.product.dimensions.weight * i.quantity, 0);
|
|
302
|
+
const shippingCost = this.calculateShipping(weight, shippingAddress.zone);
|
|
303
|
+
|
|
304
|
+
// Reaching into tax calculation
|
|
305
|
+
const taxRate = order.customer.addresses
|
|
306
|
+
.find(a => a.type === 'billing')
|
|
307
|
+
?.taxZone?.rate || 0;
|
|
308
|
+
const tax = subtotal * taxRate;
|
|
309
|
+
|
|
310
|
+
// ... 50 more lines of reaching into order internals
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Signs of Feature Envy**
|
|
316
|
+
|
|
317
|
+
| Pattern | Example | Problem |
|
|
318
|
+
|---------|---------|---------|
|
|
319
|
+
| Chain of dots | `order.customer.profile.contact.email` | Knows too much about structure |
|
|
320
|
+
| Repeated prefix | Many lines starting with `order.items.` | Should be method on Order |
|
|
321
|
+
| Type casting | `(item.product as SpecialProduct).specialProperty` | Missing polymorphism |
|
|
322
|
+
| Null checks | `order.customer?.addresses?.find(...)?.zone` | Missing null object pattern |
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
### Tight Coupling
|
|
327
|
+
|
|
328
|
+
**Report Generator Direct Instantiation**
|
|
329
|
+
```typescript
|
|
330
|
+
// VIOLATION: ReportGenerator directly instantiates all dependencies
|
|
331
|
+
class ReportGenerator {
|
|
332
|
+
async generateSalesReport(startDate: Date, endDate: Date) {
|
|
333
|
+
// Direct instantiation - can't mock for tests
|
|
334
|
+
const db = new PostgresDatabase({
|
|
335
|
+
host: process.env.DB_HOST,
|
|
336
|
+
password: process.env.DB_PASS
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// Direct instantiation - tied to specific implementation
|
|
340
|
+
const cache = new RedisCache({
|
|
341
|
+
url: process.env.REDIS_URL
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Check cache first
|
|
345
|
+
const cacheKey = `report:${startDate}:${endDate}`;
|
|
346
|
+
const cached = await cache.get(cacheKey);
|
|
347
|
+
if (cached) return cached;
|
|
348
|
+
|
|
349
|
+
// Query database directly
|
|
350
|
+
const sales = await db.query(`
|
|
351
|
+
SELECT * FROM sales
|
|
352
|
+
WHERE date BETWEEN $1 AND $2
|
|
353
|
+
`, [startDate, endDate]);
|
|
354
|
+
|
|
355
|
+
// Direct instantiation of formatter
|
|
356
|
+
const formatter = new ExcelFormatter();
|
|
357
|
+
const report = formatter.format(sales);
|
|
358
|
+
|
|
359
|
+
// Direct instantiation of storage
|
|
360
|
+
const storage = new S3Storage({
|
|
361
|
+
bucket: process.env.S3_BUCKET
|
|
362
|
+
});
|
|
363
|
+
await storage.upload(`reports/sales-${Date.now()}.xlsx`, report);
|
|
364
|
+
|
|
365
|
+
// Direct instantiation of notifier
|
|
366
|
+
const notifier = new SlackNotifier(process.env.SLACK_WEBHOOK);
|
|
367
|
+
await notifier.send('Sales report generated');
|
|
368
|
+
|
|
369
|
+
await cache.set(cacheKey, report, 3600);
|
|
370
|
+
return report;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Problems:
|
|
375
|
+
// 1. Requires real DB/Redis/S3/Slack for testing
|
|
376
|
+
// 2. Can't change providers without modifying this class
|
|
377
|
+
// 3. All configuration is hardcoded to environment variables
|
|
378
|
+
// 4. No way to use different implementations for different contexts
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Layering Violations
|
|
384
|
+
|
|
385
|
+
### Skipping Layers
|
|
386
|
+
|
|
387
|
+
**Controller Bypassing Service Layer**
|
|
388
|
+
```typescript
|
|
389
|
+
// VIOLATION: Controller directly accesses database, cache, and external APIs
|
|
390
|
+
class ProductController {
|
|
391
|
+
async getProduct(req, res) {
|
|
392
|
+
const productId = req.params.id;
|
|
393
|
+
|
|
394
|
+
// Direct cache access
|
|
395
|
+
const cached = await redis.get(`product:${productId}`);
|
|
396
|
+
if (cached) {
|
|
397
|
+
return res.json(JSON.parse(cached));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Direct database access
|
|
401
|
+
const product = await db.query(
|
|
402
|
+
'SELECT * FROM products WHERE id = $1',
|
|
403
|
+
[productId]
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
if (!product) {
|
|
407
|
+
return res.status(404).json({ error: 'Not found' });
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Direct external API call
|
|
411
|
+
const inventory = await fetch(
|
|
412
|
+
`http://inventory-service/api/stock/${productId}`
|
|
413
|
+
).then(r => r.json());
|
|
414
|
+
|
|
415
|
+
// Business logic in controller
|
|
416
|
+
const result = {
|
|
417
|
+
...product,
|
|
418
|
+
inStock: inventory.quantity > 0,
|
|
419
|
+
availability: inventory.quantity > 10 ? 'high' : inventory.quantity > 0 ? 'low' : 'none'
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// Direct cache write
|
|
423
|
+
await redis.setex(`product:${productId}`, 300, JSON.stringify(result));
|
|
424
|
+
|
|
425
|
+
res.json(result);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async updateProduct(req, res) {
|
|
429
|
+
// Direct database update
|
|
430
|
+
await db.query(
|
|
431
|
+
'UPDATE products SET name = $1, price = $2 WHERE id = $3',
|
|
432
|
+
[req.body.name, req.body.price, req.params.id]
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
// Direct cache invalidation
|
|
436
|
+
await redis.del(`product:${req.params.id}`);
|
|
437
|
+
await redis.del('products:list');
|
|
438
|
+
|
|
439
|
+
// Direct audit log
|
|
440
|
+
await db.query(
|
|
441
|
+
'INSERT INTO audit_log (action, entity, entity_id, data) VALUES ($1, $2, $3, $4)',
|
|
442
|
+
['UPDATE', 'product', req.params.id, JSON.stringify(req.body)]
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
res.json({ success: true });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
### Leaky Abstractions
|
|
453
|
+
|
|
454
|
+
**ORM Leakage Into Domain**
|
|
455
|
+
```typescript
|
|
456
|
+
// VIOLATION: ORM/database details leak into domain and service layers
|
|
457
|
+
|
|
458
|
+
// Domain model polluted with ORM decorators and infrastructure
|
|
459
|
+
@Entity('users')
|
|
460
|
+
class User {
|
|
461
|
+
@PrimaryGeneratedColumn('uuid')
|
|
462
|
+
id: string;
|
|
463
|
+
|
|
464
|
+
@Column({ type: 'varchar', length: 255 })
|
|
465
|
+
email: string;
|
|
466
|
+
|
|
467
|
+
@Column({ type: 'varchar', length: 255, select: false })
|
|
468
|
+
password: string;
|
|
469
|
+
|
|
470
|
+
@ManyToOne(() => Organization, { lazy: true })
|
|
471
|
+
@JoinColumn({ name: 'organization_id' })
|
|
472
|
+
organization: Promise<Organization>; // Lazy loading leaks into domain
|
|
473
|
+
|
|
474
|
+
@OneToMany(() => Order, order => order.user)
|
|
475
|
+
orders: Order[];
|
|
476
|
+
|
|
477
|
+
@Column({ type: 'jsonb', default: {} })
|
|
478
|
+
metadata: Record<string, unknown>; // JSONB is infrastructure detail
|
|
479
|
+
|
|
480
|
+
@CreateDateColumn()
|
|
481
|
+
createdAt: Date;
|
|
482
|
+
|
|
483
|
+
@UpdateDateColumn()
|
|
484
|
+
updatedAt: Date;
|
|
485
|
+
|
|
486
|
+
@DeleteDateColumn()
|
|
487
|
+
deletedAt: Date | null; // Soft delete is infrastructure pattern
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Service layer knows about ORM internals
|
|
491
|
+
class UserService {
|
|
492
|
+
async getUser(id: string) {
|
|
493
|
+
const user = await this.repository.findOne({
|
|
494
|
+
where: { id, deletedAt: IsNull() }, // ORM-specific query syntax
|
|
495
|
+
relations: ['organization', 'orders'], // ORM-specific loading
|
|
496
|
+
select: ['id', 'email', 'createdAt'] // ORM-specific projection
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
// Manually handling lazy loading - ORM detail in service
|
|
500
|
+
const org = await user.organization;
|
|
501
|
+
|
|
502
|
+
return user;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
### Wrong Direction Dependencies
|
|
510
|
+
|
|
511
|
+
**Domain Depending on Infrastructure**
|
|
512
|
+
```typescript
|
|
513
|
+
// VIOLATION: Domain layer imports from infrastructure layer
|
|
514
|
+
|
|
515
|
+
// domain/order.ts
|
|
516
|
+
import { PostgresClient } from '../infrastructure/postgres';
|
|
517
|
+
import { RedisCache } from '../infrastructure/redis';
|
|
518
|
+
import { StripeClient } from '../infrastructure/stripe';
|
|
519
|
+
import { SendGridClient } from '../infrastructure/sendgrid';
|
|
520
|
+
|
|
521
|
+
class Order {
|
|
522
|
+
async save() {
|
|
523
|
+
// Domain knows about specific database
|
|
524
|
+
await PostgresClient.getInstance().query(
|
|
525
|
+
'INSERT INTO orders ...',
|
|
526
|
+
[this.id, this.items, this.total]
|
|
527
|
+
);
|
|
528
|
+
|
|
529
|
+
// Domain knows about caching
|
|
530
|
+
await RedisCache.getInstance().del(`user:${this.userId}:orders`);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
async processPayment() {
|
|
534
|
+
// Domain knows about specific payment provider
|
|
535
|
+
const stripe = new StripeClient(process.env.STRIPE_KEY);
|
|
536
|
+
await stripe.charges.create({
|
|
537
|
+
amount: this.total,
|
|
538
|
+
currency: 'usd',
|
|
539
|
+
source: this.paymentSource
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
async notifyCustomer() {
|
|
544
|
+
// Domain knows about specific email provider
|
|
545
|
+
const sendgrid = new SendGridClient(process.env.SENDGRID_KEY);
|
|
546
|
+
await sendgrid.send({
|
|
547
|
+
to: this.customerEmail,
|
|
548
|
+
template: 'order_confirmation',
|
|
549
|
+
data: { orderId: this.id }
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
**Dependency Direction Rules**
|
|
556
|
+
|
|
557
|
+
```
|
|
558
|
+
+------------------+
|
|
559
|
+
| Infrastructure | <- Implements domain interfaces
|
|
560
|
+
+------------------+
|
|
561
|
+
|
|
|
562
|
+
v
|
|
563
|
+
+------------------+
|
|
564
|
+
| Application | <- Orchestrates domain, uses interfaces
|
|
565
|
+
+------------------+
|
|
566
|
+
|
|
|
567
|
+
v
|
|
568
|
+
+------------------+
|
|
569
|
+
| Domain | <- Pure business logic, defines interfaces
|
|
570
|
+
+------------------+
|
|
571
|
+
|
|
572
|
+
Domain: No imports from other layers
|
|
573
|
+
Application: Imports from Domain only
|
|
574
|
+
Infrastructure: Imports from Domain and Application
|
|
575
|
+
```
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: complexity-patterns
|
|
3
|
+
description: Complexity analysis patterns for code review. Detects high cyclomatic complexity, deep nesting, long functions, and readability issues that hinder maintainability. Loaded by Reviewer agent when focus=complexity.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
allowed-tools: Read, Grep, Glob
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Complexity Patterns
|
|
9
|
+
|
|
10
|
+
Domain expertise for code complexity and maintainability analysis. Use alongside `review-methodology` for complete complexity reviews.
|
|
11
|
+
|
|
12
|
+
## Iron Law
|
|
13
|
+
|
|
14
|
+
> **IF YOU CAN'T UNDERSTAND IT IN 5 MINUTES, IT'S TOO COMPLEX**
|
|
15
|
+
>
|
|
16
|
+
> Every function should be explainable to a colleague in under 5 minutes. If you need a
|
|
17
|
+
> diagram to understand control flow, refactor. If you need comments to explain what
|
|
18
|
+
> (not why), the code is too clever. Simplicity is a feature, complexity is a bug.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Complexity Categories
|
|
23
|
+
|
|
24
|
+
### 1. Cyclomatic Complexity
|
|
25
|
+
|
|
26
|
+
High decision path count makes code hard to test and understand.
|
|
27
|
+
|
|
28
|
+
**Violation**: Deep nesting (5+ levels)
|
|
29
|
+
```typescript
|
|
30
|
+
if (order) {
|
|
31
|
+
if (order.items) {
|
|
32
|
+
for (const item of order.items) {
|
|
33
|
+
if (item.quantity > 0) {
|
|
34
|
+
if (item.product?.inStock) {
|
|
35
|
+
// Buried logic
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Solution**: Early returns and extraction
|
|
39
|
+
```typescript
|
|
40
|
+
function processOrder(order: Order) {
|
|
41
|
+
if (!order?.items) return;
|
|
42
|
+
for (const item of order.items) processItem(item);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function processItem(item: OrderItem) {
|
|
46
|
+
if (item.quantity <= 0 || !item.product?.inStock) return;
|
|
47
|
+
// Logic at top level
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Readability Issues
|
|
52
|
+
|
|
53
|
+
Code that requires mental effort to parse.
|
|
54
|
+
|
|
55
|
+
**Violation**: Magic values
|
|
56
|
+
```typescript
|
|
57
|
+
if (status === 3) {
|
|
58
|
+
setTimeout(callback, 86400000);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Solution**: Named constants
|
|
63
|
+
```typescript
|
|
64
|
+
const OrderStatus = { COMPLETED: 3 } as const;
|
|
65
|
+
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
66
|
+
|
|
67
|
+
if (status === OrderStatus.COMPLETED) {
|
|
68
|
+
setTimeout(callback, ONE_DAY_MS);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Maintainability Issues
|
|
73
|
+
|
|
74
|
+
Code that's expensive to change.
|
|
75
|
+
|
|
76
|
+
**Violation**: Long parameter lists
|
|
77
|
+
```typescript
|
|
78
|
+
function createUser(name, email, password, role, dept, manager, startDate, salary) { }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Solution**: Object parameter
|
|
82
|
+
```typescript
|
|
83
|
+
interface CreateUserParams {
|
|
84
|
+
name: string; email: string; password: string;
|
|
85
|
+
role: string; department: string; manager?: string;
|
|
86
|
+
startDate: Date; salary: number;
|
|
87
|
+
}
|
|
88
|
+
function createUser(params: CreateUserParams) { }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 4. Boolean Complexity
|
|
92
|
+
|
|
93
|
+
Conditions that are hard to reason about.
|
|
94
|
+
|
|
95
|
+
**Violation**: Complex boolean expression
|
|
96
|
+
```typescript
|
|
97
|
+
if (user.active && !user.deleted && (user.role === 'admin' || user.role === 'moderator') && user.verified && (!user.suspended || user.suspendedUntil < Date.now())) { }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Solution**: Extract to named predicate
|
|
101
|
+
```typescript
|
|
102
|
+
const canModerate = (user: User): boolean => {
|
|
103
|
+
if (!user.active || user.deleted || !user.verified) return false;
|
|
104
|
+
if (!['admin', 'moderator'].includes(user.role)) return false;
|
|
105
|
+
if (user.suspended && user.suspendedUntil >= Date.now()) return false;
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
if (canModerate(user)) { }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Extended References
|
|
115
|
+
|
|
116
|
+
For extended examples and detection techniques:
|
|
117
|
+
|
|
118
|
+
| Reference | Content |
|
|
119
|
+
|-----------|---------|
|
|
120
|
+
| `references/violations.md` | Extended violation examples for all categories |
|
|
121
|
+
| `references/patterns.md` | Detailed refactoring solutions |
|
|
122
|
+
| `references/detection.md` | Bash commands and static analysis setup |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Severity Guidelines
|
|
127
|
+
|
|
128
|
+
| Severity | Criteria |
|
|
129
|
+
|----------|----------|
|
|
130
|
+
| **CRITICAL** | Functions > 200 lines, complexity > 20, nesting > 6, duplication in 5+ places |
|
|
131
|
+
| **HIGH** | Functions 50-200 lines, complexity 10-20, nesting 4-6, 5+ boolean conditions, 5+ parameters |
|
|
132
|
+
| **MEDIUM** | Functions 30-50 lines, complexity 5-10, magic values, minor duplication |
|
|
133
|
+
| **LOW** | Could be more readable, naming improvements, comments would help |
|
|
134
|
+
|
|
135
|
+
## Metrics Quick Reference
|
|
136
|
+
|
|
137
|
+
| Metric | Good | Warning | Critical |
|
|
138
|
+
|--------|------|---------|----------|
|
|
139
|
+
| Function length | < 30 | 30-50 | > 50 |
|
|
140
|
+
| Cyclomatic complexity | < 5 | 5-10 | > 10 |
|
|
141
|
+
| Nesting depth | < 3 | 3-4 | > 4 |
|
|
142
|
+
| Parameters | < 3 | 3-5 | > 5 |
|
|
143
|
+
| File length | < 300 | 300-500 | > 500 |
|