Code Quality Workflow for @j0kz/mcp-agents
Systematic approach to improving code quality using smart-reviewer and test-generator MCP tools.
When to Use This Workflow
-
Before creating pull request - Pre-PR quality gate
-
After significant refactoring - Verify no regressions
-
During codebase audits - Systematic quality improvement
-
When CI/CD quality checks fail - Fix issues systematically
-
Adding new features - Ensure quality from start
5-Step Quality Pattern
- Initial Assessment → Identify files needing review
- Smart Review → Categorize issues (critical/moderate/minor)
- Auto-Fix (Pareto 80/20) → Apply safe fixes automatically
- Generate Tests → Cover untested code
- Re-Review → Verify improvements
Quick Start
For Changed Files (Pre-PR)
Get changed files
git diff --name-only main...HEAD | grep -E '.(ts|js)$'
Batch Review
Tool: batch_review Input: { "filePaths": ["file1.ts", "file2.ts"], "config": { "severity": "strict" } }
Apply Auto-Fixes
Tool: apply_auto_fixes Input: { "filePath": "src/module.ts", "safeOnly": true // Always true for automation }
Generate Tests
Tool: write_test_file Input: { "sourceFile": "src/module.ts", "config": { "framework": "vitest", "coverage": 80 } }
Severity Configuration
Level Use For What It Flags
strict Production, APIs, Security ALL vulnerabilities, type violations, complexity >50
moderate Standard development, PRs Critical issues, complexity >70, major gaps
lenient Prototypes, experiments Only severe issues, breaking errors
For detailed severity configuration:
cat .claude/skills/code-quality-pipeline/references/severity-config-guide.md
Auto-Fix with Pareto Principle
Key Insight: 20% of fixes resolve 80% of issues
Safe Auto-Fixes (Apply Automatically)
-
Formatting & indentation
-
Import organization
-
Unused code removal
-
Simple type fixes
-
Naming consistency
Manual Fixes (Review Required)
-
Logic changes
-
Refactoring suggestions
-
Architecture improvements
-
Complex type inference
For complete auto-fix patterns:
cat .claude/skills/code-quality-pipeline/references/auto-fix-patterns.md
Test Generation
Configuration
{ "framework": "vitest", // Standard for @j0kz "includeEdgeCases": true, // Boundary conditions "includeErrorCases": true, // Error paths "coverage": 80 // Target percentage }
What Gets Generated
-
Unit tests for functions
-
Edge cases (null, empty, boundaries)
-
Error handling tests
-
Async operation tests
-
Mock setups
For test generation details:
cat .claude/skills/code-quality-pipeline/references/test-generation-guide.md
Common Patterns
Pattern 1: Fast Pre-Commit
Time: 1-2 minutes
- Review staged files (moderate)
- Apply safe auto-fixes
- Run tests
Pattern 2: Comprehensive Pre-PR
Time: 5-15 minutes
- Review all changes (strict)
- Auto-fix safe issues
- Manual fix critical issues
- Generate missing tests
- Verify coverage >75%
Pattern 3: Legacy Code Improvement
Time: 30-60 minutes
- Review with moderate severity
- Apply all safe fixes
- Fix critical issues manually
- Generate test suite
- Re-review for verification
For complete workflow examples:
cat .claude/skills/code-quality-pipeline/references/complete-workflow-examples.md
Expected Outcomes
After Auto-Fix (Safe Only)
Issues: -73% average reduction Formatting: 100% consistent Imports: 100% organized Dead code: 100% removed
After Full Pipeline
Critical issues: 0 Complexity: <50 Coverage: >75% Maintainability: >80
Issue Priority Guide
Critical (Fix Before Merge)
-
Security vulnerabilities
-
Type safety violations
-
Resource leaks
-
Null/undefined errors
Moderate (Fix If Time)
-
High complexity (>70)
-
Missing documentation
-
Performance issues
-
Duplicate code
Minor (Future Cleanup)
-
Style preferences
-
Micro-optimizations
-
Comment improvements
Integration with Other Tools
With orchestrator-mcp
Tool: run_workflow Input: { "workflow": "pre-merge", "params": { "files": ["..."] } }
With modular-refactoring
After quality pipeline, if complexity >50:
-
Apply modular-refactoring-pattern
-
Split files >300 LOC
-
Extract to helpers/utils
Troubleshooting
Issue Solution
"Too many issues" Use auto-fix for 80% reduction
"Tests failing" Check if bugs found (good!) or mocks needed
"Auto-fix broke code" Restore from .backup/, use safeOnly=true
"Inconsistent results" Check severity level appropriateness
Quick Commands
After quality improvements
npm test # Run tests npm run test:coverage # Check coverage npm run update:test-count # Update badges git diff # Review changes
Related Skills
-
mcp-workflow-composition: Orchestrate multiple tools
-
modular-refactoring-pattern: Reduce complexity
-
testing-patterns-vitest: Deep testing guidance
Scripts Available
Check the scripts/ directory for automation:
ls .claude/skills/code-quality-pipeline/scripts/
For project standards: .claude/skills/project-standardization/SKILL.md
For workflow orchestration: .claude/skills/mcp-workflow-composition/SKILL.md