
When Auditing Code Style Use Style Audit
- 1 installs
- 404 repo stars
- Updated August 5, 2026
- aiskillstore/marketplace
when-auditing-code-style-use-style-audit is a skill that runs a codebase-wide code style and convention audit with safe auto-fix across ESLint, Prettier, TypeScript, and naming rules.
About
when-auditing-code-style-use-style-audit performs a codebase-wide code style and convention audit with automated fixes. A developer uses it to run ESLint, Prettier, and TypeScript strict scans, check naming conventions, and enforce file and function size limits. It applies only safe, non-destructive auto-fixes and reports measurable compliance metrics.
- Comprehensive code style audit with safe auto-fix
- Runs ESLint, Prettier, and TypeScript strict checks
- Validates naming conventions and file organization limits
When Auditing Code Style Use Style Audit by the numbers
- 1 all-time installs (skills.sh)
- Ranked #984 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
when-auditing-code-style-use-style-audit capabilities & compatibility
- Capabilities
- code review · refactoring
- Use cases
- code review · refactoring
What when-auditing-code-style-use-style-audit says it does
Code style and conventions audit with auto-fix capabilities for comprehensive style enforcement
Identifies style violations, enforces naming conventions, validates formatting, and applies automated corrections
npx skills add https://github.com/aiskillstore/marketplace --skill when-auditing-code-style-use-style-auditAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 404 |
| Last updated | August 5, 2026 |
| Repository | aiskillstore/marketplace ↗ |
What it does
Audit a codebase for style and convention violations and apply safe automated fixes.
Who is it for?
Enforcing consistent code style and naming across a codebase with safe auto-fixes
Skip if: Deep logic bugs or security review beyond style and conventions
When should I use this skill?
You need a codebase-wide style, formatting, and naming-convention audit
What you get
A style audit report with measurable compliance and safe automated corrections applied
- Style audit report with compliance metrics
- Safe auto-fixed style violations
By the numbers
- Enforces max file length 500 lines, max function length 50 lines, max 4 parameters, max nesting depth 4
Files
Code Style Audit with Auto-Fix
Purpose
Perform comprehensive code style and conventions audit across the entire codebase with automated fix capabilities. Identifies style violations, enforces naming conventions, validates formatting, and applies automated corrections to ensure consistent code quality.
Core Principles
- Automated Enforcement: Auto-fix for style violations where possible
- Comprehensive Coverage: ESLint, Prettier, TypeScript, naming conventions
- Evidence-Based: Measurable style compliance metrics
- Non-Breaking: Only applies safe, non-destructive fixes
- Continuous Compliance: Style validation at every commit
Phase 1: Scan Codebase
Objective
Identify all style violations, formatting issues, and convention inconsistencies across the codebase.
Agent Configuration
agent: code-analyzer
specialization: style-scanning
tools: ESLint, Prettier, TypeScriptExecution Steps
1. Initialize Style Scan
# Pre-task setup
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Comprehensive code style scanning" \
--task-type "style-scan"
# Restore session context
npx claude-flow@alpha hooks session-restore \
--session-id "style-audit-${AUDIT_ID}" \
--agent-id "code-analyzer"2. ESLint Comprehensive Scan
# Run ESLint with all rules
npx eslint . \
--ext .js,.jsx,.ts,.tsx \
--format json \
--output-file eslint-report.json \
--max-warnings 0
# Separate auto-fixable vs manual issues
npx eslint . \
--ext .js,.jsx,.ts,.tsx \
--format json \
--fix-dry-run > eslint-fixable-report.json3. Prettier Formatting Check
# Check all supported file types
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}" \
--list-different > prettier-violations.txt
# Check configuration consistency
npx prettier --find-config-path . > prettier-config-check.txt4. TypeScript Style Validation
# Strict type checking
npx tsc --noEmit --strict --pretty false 2> typescript-strict-errors.txt
# Check for any types
grep -r ": any" src/ --include="*.ts" --include="*.tsx" > any-types.txt
# Check for implicit any
npx tsc --noImplicitAny --noEmit 2> implicit-any-errors.txt5. Naming Convention Analysis
// Naming patterns validation
const namingConventions = {
// File naming
files: {
pattern: /^[a-z][a-z0-9-]*\.(js|ts|jsx|tsx)$/,
examples: ['user-service.js', 'api-client.ts'],
violations: []
},
// Directory naming
directories: {
pattern: /^[a-z][a-z0-9-]*$/,
examples: ['user-api', 'auth-service'],
violations: []
},
// Class naming (PascalCase)
classes: {
pattern: /^[A-Z][a-zA-Z0-9]*$/,
examples: ['UserService', 'ApiClient'],
violations: []
},
// Function naming (camelCase)
functions: {
pattern: /^[a-z][a-zA-Z0-9]*$/,
examples: ['getUserById', 'calculateTotal'],
violations: []
},
// Constant naming (UPPER_SNAKE_CASE)
constants: {
pattern: /^[A-Z][A-Z0-9_]*$/,
examples: ['MAX_RETRIES', 'API_BASE_URL'],
violations: []
},
// React component naming (PascalCase)
components: {
pattern: /^[A-Z][a-zA-Z0-9]*$/,
examples: ['UserProfile', 'LoginForm'],
violations: []
},
// Private methods (leading underscore)
privateMethods: {
pattern: /^_[a-z][a-zA-Z0-9]*$/,
examples: ['_validateInput', '_processData'],
violations: []
}
};
// Scan for naming violations
function scanNamingViolations(ast) {
ast.walk((node) => {
if (node.type === 'ClassDeclaration') {
if (!namingConventions.classes.pattern.test(node.id.name)) {
namingConventions.classes.violations.push({
file: node.loc.source,
line: node.loc.start.line,
found: node.id.name,
expected: toPascalCase(node.id.name)
});
}
}
// Similar checks for other node types...
});
}6. Code Organization Violations
// File organization rules
const organizationRules = {
max_file_length: {
threshold: 500,
unit: 'lines',
violations: []
},
max_function_length: {
threshold: 50,
unit: 'lines',
violations: []
},
max_function_parameters: {
threshold: 4,
unit: 'parameters',
violations: []
},
max_nesting_depth: {
threshold: 4,
unit: 'levels',
violations: []
},
import_organization: {
rules: [
'External imports first',
'Internal imports second',
'Relative imports last',
'Alphabetically sorted within groups'
],
violations: []
},
export_organization: {
rules: [
'Named exports grouped',
'Default export last',
'No mixed inline and end-of-file exports'
],
violations: []
}
};
// Check file length
function checkFileLength(filePath) {
const lines = fs.readFileSync(filePath, 'utf8').split('\n').length;
if (lines > organizationRules.max_file_length.threshold) {
organizationRules.max_file_length.violations.push({
file: filePath,
lines: lines,
excess: lines - organizationRules.max_file_length.threshold
});
}
}7. Generate Scan Report
## Code Style Audit - Scan Results
### ESLint Violations
**Total: 247 issues (189 errors, 58 warnings)**
#### By Category
| Category | Count | Auto-Fixable |
|----------|-------|--------------|
| Formatting | 123 | 123 ✅ |
| Best Practices | 45 | 28 ✅ |
| Possible Errors | 34 | 12 ✅ |
| Variables | 28 | 18 ✅ |
| ES6 | 17 | 8 ✅ |
#### Top Violations
1. `indent` (2 spaces): 67 occurrences
2. `no-unused-vars`: 34 occurrences
3. `prefer-const`: 28 occurrences
4. `no-console`: 23 occurrences
5. `quotes` (single): 19 occurrences
### Prettier Violations
**Total: 147 files need formatting**
- Inconsistent quote style (single vs double): 89 files
- Missing trailing commas: 67 files
- Incorrect indentation: 45 files
- Line length exceeded (>100 chars): 34 files
### TypeScript Issues
**Total: 67 issues**
- Explicit `any` types: 23 occurrences
- Implicit `any` warnings: 31 occurrences
- Strict null checks: 13 occurrences
### Naming Convention Violations
**Total: 89 violations**
| Convention | Violations | Examples |
|------------|------------|----------|
| File naming | 23 | `UserService.js` → `user-service.js` |
| Class naming | 12 | `apiClient` → `ApiClient` |
| Function naming | 18 | `GetUserById` → `getUserById` |
| Constant naming | 15 | `maxRetries` → `MAX_RETRIES` |
| Variable naming | 21 | `user_id` → `userId` |
### Code Organization Issues
**Total: 56 violations**
- Files exceeding 500 lines: 12 files
- Functions exceeding 50 lines: 28 functions
- Functions with >4 parameters: 8 functions
- Nesting depth >4 levels: 8 occurrences
### Summary
- **Auto-fixable**: 189/247 ESLint issues (76.5%)
- **Manual fixes required**: 58 ESLint issues
- **Prettier auto-fixable**: 147 files (100%)
- **Naming convention fixes**: 89 (requires refactoring)8. Store Scan Results
npx claude-flow@alpha hooks post-edit \
--file "style-scan-report.json" \
--memory-key "swarm/code-analyzer/scan-results" \
--metadata "{\"total_violations\": ${TOTAL_VIOLATIONS}, \"auto_fixable\": ${AUTO_FIXABLE}}"Validation Gates
- ✅ Complete codebase scanned
- ✅ All violation types identified
- ✅ Auto-fixable issues flagged
- ✅ Manual issues documented
Expected Outputs
eslint-report.json- ESLint violationsprettier-violations.txt- Formatting issuestypescript-strict-errors.txt- Type issuesnaming-violations.json- Naming convention issuesstyle-scan-report.json- Comprehensive scan results
---
Phase 2: Compare to Standards
Objective
Compare scanned violations against project coding standards and industry best practices.
Agent Configuration
agent: reviewer
specialization: standards-comparison
standards: Airbnb, Google, StandardJSExecution Steps
1. Initialize Standards Comparison
npx claude-flow@alpha hooks pre-task \
--agent-id "reviewer" \
--description "Compare violations to coding standards" \
--task-type "standards-comparison"2. Load Project Standards
// Load project coding standards
const projectStandards = {
eslint_config: require('./.eslintrc.json'),
prettier_config: require('./.prettierrc.json'),
typescript_config: require('./tsconfig.json'),
// Custom conventions
naming_conventions: require('./docs/coding-standards.md'),
file_organization: require('./docs/file-structure.md'),
// Base standards
base_standard: 'airbnb' // or 'google', 'standard'
};3. Compare ESLint Configuration
// Check ESLint config completeness
const eslintComparison = {
configured_rules: Object.keys(projectStandards.eslint_config.rules).length,
airbnb_rules: 247, // Airbnb ESLint config
missing_rules: [],
conflicting_rules: [],
disabled_rules: [],
// Rule categories
formatting_rules: 0,
best_practices_rules: 0,
error_prevention_rules: 0,
es6_rules: 0
};
// Identify missing important rules
const criticalRules = [
'no-var',
'prefer-const',
'no-unused-vars',
'no-console',
'eqeqeq',
'no-implicit-globals',
'strict'
];
criticalRules.forEach(rule => {
if (!projectStandards.eslint_config.rules[rule]) {
eslintComparison.missing_rules.push(rule);
}
});4. Compare Prettier Configuration
// Prettier standard comparison
const prettierComparison = {
configured: projectStandards.prettier_config,
recommended: {
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
quoteProps: 'as-needed',
trailingComma: 'es5',
bracketSpacing: true,
arrowParens: 'always'
},
differences: []
};
// Compare configurations
Object.keys(prettierComparison.recommended).forEach(key => {
const projectValue = projectStandards.prettier_config[key];
const recommendedValue = prettierComparison.recommended[key];
if (projectValue !== recommendedValue) {
prettierComparison.differences.push({
option: key,
project: projectValue,
recommended: recommendedValue
});
}
});5. Assess TypeScript Strictness
// TypeScript strictness comparison
const typescriptComparison = {
current_strictness: projectStandards.typescript_config.compilerOptions.strict || false,
strict_options: {
noImplicitAny: projectStandards.typescript_config.compilerOptions.noImplicitAny,
noImplicitThis: projectStandards.typescript_config.compilerOptions.noImplicitThis,
alwaysStrict: projectStandards.typescript_config.compilerOptions.alwaysStrict,
strictNullChecks: projectStandards.typescript_config.compilerOptions.strictNullChecks,
strictFunctionTypes: projectStandards.typescript_config.compilerOptions.strictFunctionTypes,
strictBindCallApply: projectStandards.typescript_config.compilerOptions.strictBindCallApply,
strictPropertyInitialization: projectStandards.typescript_config.compilerOptions.strictPropertyInitialization
},
recommended_strictness: true,
recommendations: []
};
// Generate recommendations
if (!typescriptComparison.current_strictness) {
typescriptComparison.recommendations.push('Enable "strict": true');
}
Object.keys(typescriptComparison.strict_options).forEach(option => {
if (!typescriptComparison.strict_options[option]) {
typescriptComparison.recommendations.push(`Enable "${option}": true`);
}
});6. Generate Standards Comparison Report
## Standards Comparison Report
### ESLint Configuration
**Configured Rules**: 178 / 247 (72.1%)
**Base Standard**: Airbnb
#### Missing Critical Rules (7)
1. `no-var` - Disallow var, use let/const
2. `prefer-const` - Prefer const for unchanged variables
3. `no-implicit-globals` - Disallow implicit global variables
4. `strict` - Require strict mode
5. `no-shadow` - Disallow variable shadowing
6. `no-param-reassign` - Disallow parameter reassignment
7. `consistent-return` - Require consistent return
#### Conflicting Rules (3)
- `indent`: Project uses 4 spaces, Airbnb recommends 2
- `quotes`: Project uses double, Airbnb recommends single
- `comma-dangle`: Project disabled, Airbnb requires
#### Disabled Important Rules (5)
- `no-console` - Currently disabled, should be error
- `no-debugger` - Currently disabled, should be error
- `no-alert` - Currently disabled, should be warning
### Prettier Configuration
**Configuration Completeness**: 8 / 9 options (88.9%)
#### Configuration Differences from Recommended
| Option | Project | Recommended | Impact |
|--------|---------|-------------|--------|
| `singleQuote` | false | true | Inconsistent with ESLint |
| `printWidth` | 80 | 100 | More line breaks than needed |
### TypeScript Configuration
**Strict Mode**: ❌ Disabled
**Individual Strict Checks**: 3 / 7 enabled (42.9%)
#### Recommendations
1. Enable `"strict": true` (enables all strict checks)
2. Enable `noImplicitAny` for better type safety
3. Enable `strictNullChecks` to catch null/undefined errors
4. Enable `strictFunctionTypes` for safer function typing
### Naming Conventions
**Documented**: ✅ Yes (docs/coding-standards.md)
**Enforced**: ⚠️ Partial (ESLint naming rules not configured)
#### Recommendations
1. Add `@typescript-eslint/naming-convention` rule
2. Configure naming patterns for:
- Classes (PascalCase)
- Functions/variables (camelCase)
- Constants (UPPER_SNAKE_CASE)
- Private members (leading underscore)
### File Organization
**Max File Length**: 500 lines ✅
**Max Function Length**: 50 lines ✅
**Import Ordering**: ⚠️ Not enforced
#### Recommendations
1. Add `import/order` ESLint rule
2. Configure import groups:
- External dependencies
- Internal modules
- Relative imports7. Store Comparison Results
npx claude-flow@alpha hooks post-edit \
--file "standards-comparison-report.json" \
--memory-key "swarm/reviewer/standards-comparison" \
--metadata "{\"compliance_pct\": ${COMPLIANCE_PCT}, \"missing_rules\": ${MISSING_RULES_COUNT}}"Validation Gates
- ✅ Standards documented
- ✅ Comparison complete
- ✅ Gaps identified
- ✅ Recommendations generated
Expected Outputs
standards-comparison-report.json- Detailed comparisonmissing-rules.json- Rules to addconfig-recommendations.json- Configuration improvements
---
Phase 3: Report Violations
Objective
Generate comprehensive violation reports with prioritization, categorization, and fix recommendations.
Agent Configuration
agent: code-analyzer
specialization: violation-reporting
output: HTML, JSON, MarkdownExecution Steps
1. Initialize Violation Reporting
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Generate violation reports" \
--task-type "violation-reporting"2. Prioritize Violations
// Prioritization criteria
const violationPriority = {
P0_CRITICAL: {
description: 'Breaking production issues, security risks',
examples: ['no-eval', 'no-implied-eval', 'no-script-url'],
violations: []
},
P1_HIGH: {
description: 'Potential bugs, code smells',
examples: ['no-unused-vars', 'no-unreachable', 'no-fallthrough'],
violations: []
},
P2_MEDIUM: {
description: 'Best practices, maintainability',
examples: ['prefer-const', 'no-var', 'eqeqeq'],
violations: []
},
P3_LOW: {
description: 'Formatting, style consistency',
examples: ['indent', 'quotes', 'comma-dangle'],
violations: []
}
};
// Categorize violations by priority
function prioritizeViolations(violations) {
violations.forEach(violation => {
const rule = violation.ruleId;
if (violationPriority.P0_CRITICAL.examples.includes(rule)) {
violationPriority.P0_CRITICAL.violations.push(violation);
} else if (violationPriority.P1_HIGH.examples.includes(rule)) {
violationPriority.P1_HIGH.violations.push(violation);
} else if (violationPriority.P2_MEDIUM.examples.includes(rule)) {
violationPriority.P2_MEDIUM.violations.push(violation);
} else {
violationPriority.P3_LOW.violations.push(violation);
}
});
}3. Categorize by File/Module
// Group violations by file
const violationsByFile = {};
function categorizeByFile(violations) {
violations.forEach(violation => {
const file = violation.filePath;
if (!violationsByFile[file]) {
violationsByFile[file] = {
file: file,
total_violations: 0,
critical: 0,
high: 0,
medium: 0,
low: 0,
violations: []
};
}
violationsByFile[file].violations.push(violation);
violationsByFile[file].total_violations++;
// Increment priority counters
if (violation.priority === 'P0_CRITICAL') violationsByFile[file].critical++;
if (violation.priority === 'P1_HIGH') violationsByFile[file].high++;
if (violation.priority === 'P2_MEDIUM') violationsByFile[file].medium++;
if (violation.priority === 'P3_LOW') violationsByFile[file].low++;
});
// Sort by total violations descending
return Object.values(violationsByFile)
.sort((a, b) => b.total_violations - a.total_violations);
}4. Generate Fix Recommendations
// Auto-fix recommendations
const fixRecommendations = {
auto_fixable: {
count: 0,
script: 'npx eslint . --fix && npx prettier --write "**/*.{js,ts,jsx,tsx}"',
violations: []
},
semi_auto_fixable: {
count: 0,
description: 'Requires code review after auto-fix',
violations: []
},
manual_fix_required: {
count: 0,
description: 'Requires human judgment and refactoring',
violations: []
}
};
// Generate fix instructions for each violation
function generateFixInstructions(violation) {
const instructions = {
rule: violation.ruleId,
file: violation.filePath,
line: violation.line,
column: violation.column,
fix_type: 'auto', // 'auto', 'semi-auto', 'manual'
fix_command: null,
fix_description: null,
before: violation.source,
after: null
};
// Rule-specific fix instructions
switch (violation.ruleId) {
case 'no-unused-vars':
instructions.fix_type = 'manual';
instructions.fix_description = 'Remove unused variable or add usage';
break;
case 'prefer-const':
instructions.fix_type = 'auto';
instructions.fix_command = 'npx eslint --fix';
instructions.after = violation.source.replace('let ', 'const ');
break;
case 'no-console':
instructions.fix_type = 'manual';
instructions.fix_description = 'Remove console.log or use proper logging';
break;
// Add more rule-specific instructions...
}
return instructions;
}5. Generate Violation Reports
## Code Style Violations Report
### Executive Summary
- **Total Violations**: 247
- **Critical (P0)**: 0 ✅
- **High (P1)**: 34
- **Medium (P2)**: 73
- **Low (P3)**: 140
### Auto-Fix Summary
- **Auto-fixable**: 189 (76.5%)
- **Semi-auto-fixable**: 23 (9.3%)
- **Manual fix required**: 35 (14.2%)
### Top 10 Worst Files
| File | Total | P0 | P1 | P2 | P3 |
|------|-------|----|----|----|----|
| src/api/order-processor.js | 45 | 0 | 12 | 18 | 15 |
| src/utils/data-transformer.js | 38 | 0 | 8 | 15 | 15 |
| src/api/user-controller.js | 32 | 0 | 6 | 12 | 14 |
| src/services/payment.js | 28 | 0 | 5 | 10 | 13 |
| src/utils/validator.js | 24 | 0 | 3 | 9 | 12 |
### Violations by Rule (Top 10)
| Rule | Count | Priority | Auto-Fix |
|------|-------|----------|----------|
| indent | 67 | P3 | ✅ Yes |
| no-unused-vars | 34 | P1 | ❌ No |
| prefer-const | 28 | P2 | ✅ Yes |
| no-console | 23 | P1 | ❌ No |
| quotes | 19 | P3 | ✅ Yes |
| semi | 17 | P3 | ✅ Yes |
| comma-dangle | 15 | P3 | ✅ Yes |
| no-var | 12 | P2 | ✅ Yes |
| eqeqeq | 8 | P1 | ⚠️ Partial |
| no-shadow | 6 | P1 | ❌ No |
### Critical Violations (P0) ✅
**None found** - Excellent!
### High Priority Violations (P1) - 34 Total
#### no-unused-vars (34 occurrences)
**Impact**: Dead code, maintenance burden, potential bugs
**Example**:// src/api/user-controller.js:45 const userId = req.params.id; // 'userId' is defined but never used
**Fix**: Remove unused variable or add usage
---
#### no-console (23 occurrences)
**Impact**: Console statements in production code
**Example**:// src/services/payment.js:78 console.log('Processing payment:', paymentData); // Unexpected console statement
**Fix**: Replace with proper logging (Winston, Bunyan)
### Medium Priority Violations (P2) - 73 Total
#### prefer-const (28 occurrences) - AUTO-FIXABLE ✅
**Impact**: Mutability when immutability intended
**Example**:// src/utils/calculator.js:23 let total = 0; // 'total' is never reassigned. Use 'const' instead total = items.reduce((sum, item) => sum + item.price, 0);
**Fix**: Run `npx eslint --fix`
### Low Priority Violations (P3) - 140 Total
#### indent (67 occurrences) - AUTO-FIXABLE ✅
**Impact**: Inconsistent formatting
**Fix**: Run `npx prettier --write "**/*.js"`
### Fix Recommendations
#### Immediate Actions (Auto-Fix)Fix all auto-fixable ESLint issues (189 issues)
npx eslint . --fix
Fix all Prettier formatting (147 files)
npx prettier --write "*/.{js,jsx,ts,tsx,json,css,md}"
Verify fixes
npm run lint npm run format:check
#### Manual Actions Required (35 issues)
1. Review and remove 34 unused variables
2. Replace 23 console.log statements with proper logging
3. Fix 6 variable shadowing issues
4. Address 8 eqeqeq violations (use === instead of ==)6. Export Multi-Format Reports
# JSON (for CI/CD)
cat style-violations-report.json
# HTML (for viewing in browser)
npx eslint . --format html --output-file eslint-report.html
# Markdown (for documentation)
cat style-violations-report.md
# CSV (for spreadsheet analysis)
node scripts/export-violations-csv.js > violations.csv7. Store Violation Reports
npx claude-flow@alpha hooks post-edit \
--file "style-violations-report.json" \
--memory-key "swarm/code-analyzer/violations-report" \
--metadata "{\"total_violations\": ${TOTAL}, \"auto_fixable_pct\": ${AUTO_FIX_PCT}}"Validation Gates
- ✅ All violations reported
- ✅ Violations prioritized
- ✅ Fix recommendations generated
- ✅ Multi-format exports created
Expected Outputs
style-violations-report.json- Complete violations datastyle-violations-report.md- Human-readable reporteslint-report.html- HTML visualizationviolations.csv- Spreadsheet-friendly format
---
Phase 4: Auto-Fix Issues
Objective
Apply automated fixes for style violations that can be safely corrected without human judgment.
Agent Configuration
agent: code-analyzer
specialization: auto-fix
safety: non-destructiveExecution Steps
1. Initialize Auto-Fix
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Apply automated style fixes" \
--task-type "auto-fix"2. Create Backup
# Create backup before applying fixes
BACKUP_DIR="style-audit-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
# Backup modified files
git diff --name-only | while read file; do
mkdir -p "$BACKUP_DIR/$(dirname "$file")"
cp "$file" "$BACKUP_DIR/$file"
done
echo "Backup created: $BACKUP_DIR"3. Apply ESLint Auto-Fixes
# Apply all auto-fixable ESLint rules
npx eslint . --fix \
--ext .js,.jsx,.ts,.tsx \
--format json \
--output-file eslint-fix-results.json
# Count fixed issues
FIXED_COUNT=$(jq '[.[] | .messages | .[] | select(.fix)] | length' eslint-fix-results.json)
echo "ESLint fixed: $FIXED_COUNT issues"4. Apply Prettier Formatting
# Format all supported files
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}" \
--log-level warn > prettier-fix-log.txt
# Count formatted files
FORMATTED_COUNT=$(grep -c "✅" prettier-fix-log.txt)
echo "Prettier formatted: $FORMATTED_COUNT files"5. Apply TypeScript Fixes
# Apply TypeScript compiler fixes (where possible)
npx tsc --noEmit --pretty false 2>&1 | \
node scripts/apply-typescript-fixes.js
# Note: Most TypeScript issues require manual intervention6. Apply Naming Convention Fixes (Safe)
// Safe automated naming fixes
const safeNamingFixes = {
// File naming: PascalCase → kebab-case
files: [
{ from: 'UserService.js', to: 'user-service.js' },
{ from: 'ApiClient.ts', to: 'api-client.ts' }
],
// Only apply if no breaking changes
safe_to_rename: true
};
// Apply file renames
function applyFileRenames() {
safeNamingFixes.files.forEach(({ from, to }) => {
if (fs.existsSync(from)) {
// Check for imports/references
const references = findReferences(from);
if (references.length === 0 || canUpdateAllReferences(references)) {
fs.renameSync(from, to);
updateAllReferences(from, to, references);
console.log(`Renamed: ${from} → ${to}`);
} else {
console.log(`Skipped: ${from} (has unmodifiable references)`);
}
}
});
}7. Verify Fixes
# Run linting again to verify
npx eslint . --format json > eslint-post-fix.json
# Compare before and after
node scripts/compare-violations.js \
eslint-report.json \
eslint-post-fix.json > fix-comparison.json
# Run tests to ensure no breakage
npm test8. Generate Fix Report
## Auto-Fix Results
### Summary
- **ESLint Fixes Applied**: 189 issues
- **Prettier Formatting**: 147 files
- **TypeScript Fixes**: 0 (manual required)
- **Naming Convention Fixes**: 0 (requires refactoring)
### ESLint Fixes
| Rule | Fixed | Remaining |
|------|-------|-----------|
| indent | 67 | 0 ✅ |
| prefer-const | 28 | 0 ✅ |
| quotes | 19 | 0 ✅ |
| semi | 17 | 0 ✅ |
| comma-dangle | 15 | 0 ✅ |
| no-var | 12 | 0 ✅ |
| **TOTAL AUTO-FIXED** | **189** | **0** ✅ |
### Prettier Formatting
- **Files formatted**: 147
- **Consistency achieved**: 100%
- **No formatting errors**: ✅
### Remaining Issues (Manual Fix Required)
- **no-unused-vars**: 34 occurrences
- **no-console**: 23 occurrences
- **eqeqeq**: 8 occurrences
- **no-shadow**: 6 occurrences
- **TOTAL MANUAL**: **71 issues**
### Tests Status
- **Unit tests**: ✅ All passing (342/342)
- **Integration tests**: ✅ All passing (89/89)
- **No regressions detected**: ✅
### Backup Location
`style-audit-backup-20250130-143022/`
### Next Steps
1. Review remaining 71 manual issues
2. Address high-priority (P1) violations first
3. Commit auto-fixed changes
4. Create issues/tasks for manual fixes9. Store Fix Results
npx claude-flow@alpha hooks post-edit \
--file "auto-fix-report.json" \
--memory-key "swarm/code-analyzer/auto-fix-results" \
--metadata "{\"fixed_count\": ${FIXED_COUNT}, \"remaining_count\": ${REMAINING_COUNT}}"Validation Gates
- ✅ Backup created
- ✅ Auto-fixes applied
- ✅ Tests pass
- ✅ No regressions
Expected Outputs
auto-fix-report.json- Fix results summaryeslint-fix-results.json- ESLint fixes detailsprettier-fix-log.txt- Prettier formatting logfix-comparison.json- Before/after comparison
---
Phase 5: Validate Compliance
Objective
Verify that all auto-fixes were applied correctly and confirm adherence to coding standards.
Agent Configuration
agent: reviewer
specialization: compliance-validation
verification: automated-testsExecution Steps
1. Initialize Compliance Validation
npx claude-flow@alpha hooks pre-task \
--agent-id "reviewer" \
--description "Validate style compliance after fixes" \
--task-type "compliance-validation"2. Run Comprehensive Linting
# ESLint validation
npx eslint . \
--ext .js,.jsx,.ts,.tsx \
--format json \
--max-warnings 0 > eslint-validation.json
# Prettier validation
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" > prettier-validation.txt
# TypeScript validation
npx tsc --noEmit --strict > typescript-validation.txt3. Calculate Compliance Metrics
// Compliance calculation
const complianceMetrics = {
eslint: {
total_rules: 247,
passing_rules: 0,
failing_rules: 0,
compliance_pct: 0
},
prettier: {
total_files: 0,
formatted_files: 0,
unformatted_files: 0,
compliance_pct: 0
},
typescript: {
total_files: 0,
error_free_files: 0,
files_with_errors: 0,
compliance_pct: 0
},
naming_conventions: {
total_identifiers: 0,
compliant_identifiers: 0,
non_compliant_identifiers: 0,
compliance_pct: 0
},
overall_compliance_pct: 0
};
// Calculate overall compliance
function calculateCompliance() {
// ESLint compliance
const eslintViolations = require('./eslint-validation.json');
const totalIssues = eslintViolations.reduce((sum, file) =>
sum + file.messages.length, 0
);
complianceMetrics.eslint.failing_rules = totalIssues;
complianceMetrics.eslint.compliance_pct =
((complianceMetrics.eslint.total_rules - totalIssues) /
complianceMetrics.eslint.total_rules) * 100;
// Prettier compliance
const prettierViolations = fs.readFileSync('prettier-validation.txt', 'utf8');
const unformattedFiles = prettierViolations.split('\n').filter(Boolean).length;
complianceMetrics.prettier.unformatted_files = unformattedFiles;
complianceMetrics.prettier.compliance_pct =
((complianceMetrics.prettier.total_files - unformattedFiles) /
complianceMetrics.prettier.total_files) * 100;
// Calculate weighted overall compliance
complianceMetrics.overall_compliance_pct = (
complianceMetrics.eslint.compliance_pct * 0.50 +
complianceMetrics.prettier.compliance_pct * 0.30 +
complianceMetrics.typescript.compliance_pct * 0.20
);
}4. Run Test Suite
# Verify no regressions from auto-fixes
npm run test:all -- --coverage
# Check for test failures
if [ $? -ne 0 ]; then
echo "❌ Tests failed after auto-fix"
echo "Rolling back changes..."
git restore .
exit 1
fi5. Validate Build
# Ensure project still builds
npm run build
# Check build size (ensure no significant increase)
BUILD_SIZE=$(du -sh dist/ | cut -f1)
echo "Build size: $BUILD_SIZE"6. Generate Compliance Report
## Style Compliance Validation Report
### Overall Compliance: 91.2% ✅
### Compliance by Category
| Category | Compliance | Status |
|----------|------------|--------|
| ESLint Rules | 95.8% | ✅ PASS (Threshold: 90%) |
| Prettier Formatting | 100% | ✅ PASS (Threshold: 100%) |
| TypeScript Strictness | 76.4% | ⚠️ WARN (Threshold: 80%) |
| Naming Conventions | 89.2% | ⚠️ WARN (Threshold: 90%) |
### ESLint Compliance
- **Total files scanned**: 247
- **Files with violations**: 11
- **Remaining violations**: 58 (down from 247)
- **Reduction**: 76.5%
#### Remaining Violations Breakdown
| Rule | Count | Priority |
|------|-------|----------|
| no-unused-vars | 34 | P1 |
| no-console | 23 | P1 |
| eqeqeq | 8 | P1 |
| no-shadow | 6 | P1 |
### Prettier Compliance
- **Total files**: 247
- **Properly formatted**: 247 (100%)
- **Consistency**: ✅ Perfect
### TypeScript Compliance
- **Files with type errors**: 18
- **Explicit `any` types**: 23
- **Implicit `any` warnings**: 31
- **Recommendation**: Enable strict mode incrementally
### Naming Conventions
- **Total identifiers**: 1,247
- **Compliant**: 1,112 (89.2%)
- **Non-compliant**: 135 (10.8%)
- File names: 23
- Class names: 12
- Function names: 18
- Variable names: 82
### Test Results
- **Unit tests**: ✅ 342/342 passing
- **Integration tests**: ✅ 89/89 passing
- **E2E tests**: ✅ 42/42 passing
- **Coverage**: 91.2% (no change)
### Build Validation
- **Build status**: ✅ Success
- **Build size**: 2.4MB (no change)
- **Build time**: 47.3s (no change)
### Compliance Gates
| Gate | Threshold | Current | Status |
|------|-----------|---------|--------|
| Overall Compliance | ≥90% | 91.2% | ✅ PASS |
| ESLint Compliance | ≥90% | 95.8% | ✅ PASS |
| Prettier Compliance | 100% | 100% | ✅ PASS |
| Tests Passing | 100% | 100% | ✅ PASS |
| No Build Errors | True | True | ✅ PASS |
### Next Steps
1. Address remaining 58 manual violations (P1 priority)
2. Enable TypeScript strict mode incrementally
3. Refactor naming convention violations
4. Schedule quarterly style audits7. Store Compliance Results
npx claude-flow@alpha hooks post-edit \
--file "compliance-validation-report.json" \
--memory-key "swarm/reviewer/compliance-validation" \
--metadata "{\"compliance_pct\": ${COMPLIANCE_PCT}, \"remaining_violations\": ${REMAINING}}"8. Commit Fixed Changes
# Stage all auto-fixed files
git add .
# Commit with detailed message
git commit -m "style: Apply automated style fixes
- ESLint auto-fixes: 189 issues resolved
- Prettier formatting: 147 files formatted
- Remaining manual fixes: 58 issues
- All tests passing
- Build verified
Audit ID: ${AUDIT_ID}
Compliance: 91.2%"Validation Gates
- ✅ Overall compliance ≥90%
- ✅ All tests passing
- ✅ Build successful
- ✅ No regressions
Expected Outputs
compliance-validation-report.json- Compliance metricseslint-validation.json- Final ESLint statusprettier-validation.txt- Final Prettier status- Git commit with auto-fixes applied
---
Final Session Cleanup
# Export complete audit session
npx claude-flow@alpha hooks session-end \
--session-id "style-audit-${AUDIT_ID}" \
--export-metrics true \
--export-path "./style-audit-summary.json"
# Notify completion
npx claude-flow@alpha hooks notify \
--message "Style audit complete: ${COMPLIANCE_PCT}% compliance" \
--level "info" \
--metadata "{\"fixed\": ${FIXED_COUNT}, \"remaining\": ${REMAINING_COUNT}}"---
Memory Patterns
Storage Keys
swarm/code-analyzer/scan-results:
total_violations: number
auto_fixable: number
manual_required: number
scan_timestamp: string
swarm/reviewer/standards-comparison:
compliance_pct: number
missing_rules: array
config_recommendations: array
swarm/code-analyzer/violations-report:
prioritized_violations: object
worst_files: array
fix_recommendations: object
swarm/code-analyzer/auto-fix-results:
fixed_count: number
remaining_count: number
backup_location: string
swarm/reviewer/compliance-validation:
overall_compliance_pct: number
remaining_violations: number
tests_passing: boolean
build_successful: boolean---
Evidence-Based Validation
Success Criteria
- ✅ Complete codebase scanned
- ✅ Violations identified and prioritized
- ✅ Auto-fixes applied safely
- ✅ Compliance ≥90%
- ✅ All tests passing
- ✅ No build regressions
Metrics Tracking
{
"audit_duration_minutes": 25,
"agents_used": 2,
"total_violations_found": 247,
"violations_auto_fixed": 189,
"violations_remaining": 58,
"compliance_before": 61.3,
"compliance_after": 91.2,
"improvement": 29.9
}---
Usage Examples
Basic Style Audit
# Run complete style audit with auto-fix
npm run style:audit
# View compliance report
cat compliance-validation-report.mdCI/CD Integration
# .github/workflows/style-audit.yml
name: Style Audit
on: [push, pull_request]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Style Audit
run: npm run style:audit
- name: Check Compliance
run: |
COMPLIANCE=$(jq '.overall_compliance_pct' style-audit-summary.json)
if [ "$COMPLIANCE" -lt 90 ]; then exit 1; fi---
Related Skills
when-reviewing-code-comprehensively-use-code-review-assistantwhen-verifying-quality-use-verification-qualitywhen-ensuring-production-ready-use-production-readiness
digraph StyleAudit {
// Graph styling
graph [rankdir=TB, fontname="Arial", fontsize=12, splines=ortho, nodesep=0.8, ranksep=1.0];
node [shape=box, style="rounded,filled", fontname="Arial", fontsize=11, fillcolor="#E3F2FD", color="#1976D2", penwidth=2];
edge [fontname="Arial", fontsize=10, color="#424242", penwidth=1.5];
// Title
label=<<B>Code Style Audit with Auto-Fix</B><BR/><FONT POINT-SIZE="10">Comprehensive Style Enforcement with Automated Corrections</FONT>>;
labelloc=t;
fontsize=16;
// Main workflow nodes
start [label="Style Audit\nInitiated", shape=ellipse, fillcolor="#C8E6C9"];
init [label="Initialize\nStyle Audit\nWorkflow", fillcolor="#FFF9C4"];
// Phase 1: Scan Codebase
phase1_start [label="Phase 1:\nScan Codebase", fillcolor="#FFCDD2", style="rounded,filled,bold"];
code_analyzer1 [label="Code Analyzer\nAgent", fillcolor="#FFEBEE"];
eslint_scan [label="ESLint Scan\n• All rules\n• Fix-dry-run"];
prettier_scan [label="Prettier Check\n• All file types\n• List different"];
typescript_scan [label="TypeScript\nValidation\n• Strict mode\n• Any types"];
naming_scan [label="Naming\nConventions\n• Files\n• Classes\n• Functions"];
organization_scan [label="Code Organization\n• File length\n• Function length\n• Nesting depth"];
scan_report [label="Scan Report\n• 247 violations\n• 189 auto-fixable\n• 58 manual", fillcolor="#FFE0B2"];
scan_store [label="Store:\nswarm/code-analyzer/\nscan-results", shape=cylinder, fillcolor="#E1F5FE"];
// Phase 2: Compare to Standards
phase2_start [label="Phase 2:\nCompare to\nStandards", fillcolor="#F8BBD0", style="rounded,filled,bold"];
reviewer1 [label="Reviewer Agent", fillcolor="#FCE4EC"];
load_standards [label="Load Standards\n• ESLint config\n• Prettier config\n• TypeScript config\n• Custom conventions"];
compare_eslint [label="Compare ESLint\n• Missing rules: 7\n• Conflicts: 3\n• Disabled: 5"];
compare_prettier [label="Compare Prettier\n• Config diffs\n• Recommendations"];
compare_typescript [label="Compare TypeScript\n• Strict mode\n• Individual checks"];
standards_report [label="Standards Report\n• ESLint: 72.1%\n• Prettier: 88.9%\n• TypeScript: 42.9%", fillcolor="#FFE0B2"];
standards_store [label="Store:\nswarm/reviewer/\nstandards-comparison", shape=cylinder, fillcolor="#E1F5FE"];
// Phase 3: Report Violations
phase3_start [label="Phase 3:\nReport\nViolations", fillcolor="#D1C4E9", style="rounded,filled,bold"];
code_analyzer2 [label="Code Analyzer\nAgent", fillcolor="#EDE7F6"];
prioritize [label="Prioritize\nViolations\n• P0: 0\n• P1: 34\n• P2: 73\n• P3: 140"];
categorize [label="Categorize\nby File\n• Top 10 worst\n• By module"];
fix_recommendations [label="Fix\nRecommendations\n• Auto-fixable: 76.5%\n• Manual: 23.5%"];
violations_report [label="Violations Report\n(Multi-Format)\n• JSON\n• Markdown\n• HTML\n• CSV", fillcolor="#FFE0B2"];
violations_store [label="Store:\nswarm/code-analyzer/\nviolations-report", shape=cylinder, fillcolor="#E1F5FE"];
// Phase 4: Auto-Fix Issues
phase4_start [label="Phase 4:\nAuto-Fix\nIssues", fillcolor="#B2DFDB", style="rounded,filled,bold"];
code_analyzer3 [label="Code Analyzer\nAgent", fillcolor="#E0F2F1"];
backup [label="Create Backup\n• Git stash\n• Timestamped"];
eslint_fix [label="ESLint --fix\n• 189 issues fixed\n• Auto-fixable only"];
prettier_fix [label="Prettier --write\n• 147 files formatted\n• All formatting"];
typescript_fix [label="TypeScript Fixes\n• Limited auto-fix\n• Manual mostly"];
naming_fix [label="Safe Naming Fixes\n• File renames\n• Reference updates"];
verify [label="Verify Fixes\n• Run tests\n• Check build"];
fix_report [label="Auto-Fix Report\n• Fixed: 189\n• Remaining: 58\n• Tests: Pass ✅", fillcolor="#FFE0B2"];
fix_store [label="Store:\nswarm/code-analyzer/\nauto-fix-results", shape=cylinder, fillcolor="#E1F5FE"];
// Phase 5: Validate Compliance
phase5_start [label="Phase 5:\nValidate\nCompliance", fillcolor="#C5CAE9", style="rounded,filled,bold"];
reviewer2 [label="Reviewer Agent", fillcolor="#E8EAF6"];
run_linting [label="Run All Linters\n• ESLint\n• Prettier\n• TypeScript"];
calculate_metrics [label="Calculate\nCompliance\n• By category\n• Overall weighted"];
run_tests [label="Run Test Suite\n• Unit\n• Integration\n• E2E"];
validate_build [label="Validate Build\n• Build success\n• Size check"];
compliance_report [label="Compliance Report\n• Overall: 91.2%\n• Tests: Pass ✅\n• Build: Success ✅", fillcolor="#FFE0B2"];
compliance_store [label="Store:\nswarm/reviewer/\ncompliance-validation", shape=cylinder, fillcolor="#E1F5FE"];
// Decision
decision [label="Compliance\n≥ 90%\nAND\nTests Pass?", shape=diamond, fillcolor="#FFECB3", style="filled"];
approved [label="AUDIT\nPASSED\n✅", fillcolor="#C8E6C9", style="rounded,filled,bold"];
rejected [label="ADDITIONAL\nFIXES NEEDED\n⚠️", fillcolor="#FFCDD2", style="rounded,filled,bold"];
commit [label="Commit\nAuto-Fixes\n+ Report", fillcolor="#FFF9C4"];
notify [label="Notify Team\n& Update\nDashboard", fillcolor="#E1F5FE"];
end [label="Style Audit\nComplete", shape=ellipse, fillcolor="#C8E6C9"];
// Main flow
start -> init;
init -> phase1_start;
// Phase 1 flow
phase1_start -> code_analyzer1;
code_analyzer1 -> eslint_scan;
code_analyzer1 -> prettier_scan;
code_analyzer1 -> typescript_scan;
code_analyzer1 -> naming_scan;
code_analyzer1 -> organization_scan;
eslint_scan -> scan_report;
prettier_scan -> scan_report;
typescript_scan -> scan_report;
naming_scan -> scan_report;
organization_scan -> scan_report;
scan_report -> scan_store;
scan_store -> phase2_start;
// Phase 2 flow
phase2_start -> reviewer1;
reviewer1 -> load_standards;
load_standards -> compare_eslint;
load_standards -> compare_prettier;
load_standards -> compare_typescript;
compare_eslint -> standards_report;
compare_prettier -> standards_report;
compare_typescript -> standards_report;
standards_report -> standards_store;
standards_store -> phase3_start;
// Phase 3 flow
phase3_start -> code_analyzer2;
code_analyzer2 -> prioritize;
code_analyzer2 -> categorize;
code_analyzer2 -> fix_recommendations;
prioritize -> violations_report;
categorize -> violations_report;
fix_recommendations -> violations_report;
violations_report -> violations_store;
violations_store -> phase4_start;
// Phase 4 flow
phase4_start -> code_analyzer3;
code_analyzer3 -> backup;
backup -> eslint_fix;
backup -> prettier_fix;
backup -> typescript_fix;
backup -> naming_fix;
eslint_fix -> verify;
prettier_fix -> verify;
typescript_fix -> verify;
naming_fix -> verify;
verify -> fix_report;
fix_report -> fix_store;
fix_store -> phase5_start;
// Phase 5 flow
phase5_start -> reviewer2;
reviewer2 -> run_linting;
reviewer2 -> calculate_metrics;
reviewer2 -> run_tests;
reviewer2 -> validate_build;
run_linting -> compliance_report;
calculate_metrics -> compliance_report;
run_tests -> compliance_report;
validate_build -> compliance_report;
compliance_report -> compliance_store;
compliance_store -> decision;
// Decision branches
decision -> approved [label="Yes\n(≥90%)", color="#4CAF50", penwidth=2];
decision -> rejected [label="No\n(<90%)", color="#F44336", penwidth=2];
// Approved path
approved -> commit;
commit -> notify;
// Rejected path
rejected -> notify [label="Manual\nfixes\nrequired"];
// Final step
notify -> end;
// Visual grouping with subgraphs
subgraph cluster_phase1 {
label="Phase 1: Scan Codebase (8 min)";
style=dashed;
color="#F44336";
eslint_scan; prettier_scan; typescript_scan; naming_scan; organization_scan; scan_report; scan_store;
}
subgraph cluster_phase2 {
label="Phase 2: Compare to Standards (5 min)";
style=dashed;
color="#E91E63";
load_standards; compare_eslint; compare_prettier; compare_typescript; standards_report; standards_store;
}
subgraph cluster_phase3 {
label="Phase 3: Report Violations (5 min)";
style=dashed;
color="#9C27B0";
prioritize; categorize; fix_recommendations; violations_report; violations_store;
}
subgraph cluster_phase4 {
label="Phase 4: Auto-Fix Issues (5 min)";
style=dashed;
color="#009688";
backup; eslint_fix; prettier_fix; typescript_fix; naming_fix; verify; fix_report; fix_store;
}
subgraph cluster_phase5 {
label="Phase 5: Validate Compliance (2 min)";
style=dashed;
color="#3F51B5";
run_linting; calculate_metrics; run_tests; validate_build; compliance_report; compliance_store;
}
// Legend
subgraph cluster_legend {
label="Legend";
style=filled;
fillcolor="#FAFAFA";
color="#9E9E9E";
leg_phase [label="Phase Start", fillcolor="#FFCDD2", style="rounded,filled,bold"];
leg_agent [label="Agent", fillcolor="#FFEBEE"];
leg_action [label="Action", fillcolor="#E3F2FD"];
leg_report [label="Report", fillcolor="#FFE0B2"];
leg_memory [label="Memory", shape=cylinder, fillcolor="#E1F5FE"];
leg_decision [label="Decision", shape=diamond, fillcolor="#FFECB3"];
leg_phase -> leg_agent -> leg_action -> leg_report -> leg_memory -> leg_decision [style=invis];
}
}
Code Style Audit Process Walkthrough
Overview
This process executes comprehensive code style audit across 5 phases: scan codebase, compare to standards, report violations, auto-fix issues, and validate compliance.
---
Phase 1: Scan Codebase (8 minutes)
Agent: code-analyzer
Purpose: Identify all style violations, formatting issues, and convention inconsistencies.
Steps
1. Initialize Style Scan
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Comprehensive code style scanning"2. Run ESLint Scan
# Complete ESLint scan
npx eslint . --ext .js,.jsx,.ts,.tsx --format json > eslint-report.json
# Identify auto-fixable issues
npx eslint . --ext .js,.jsx,.ts,.tsx --format json --fix-dry-run > eslint-fixable-report.json3. Run Prettier Check
# Check formatting violations
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" --list-different > prettier-violations.txt4. Run TypeScript Validation
# Strict type checking
npx tsc --noEmit --strict > typescript-strict-errors.txt
# Check for any types
grep -r ": any" src/ --include="*.ts" --include="*.tsx" > any-types.txt5. Analyze Naming Conventions
- Files: kebab-case (user-service.js)
- Classes: PascalCase (UserService)
- Functions: camelCase (getUserById)
- Constants: UPPER_SNAKE_CASE (MAX_RETRIES)
- Components: PascalCase (LoginForm)
6. Check Code Organization
- Max file length: 500 lines
- Max function length: 50 lines
- Max parameters: 4
- Max nesting depth: 4
7. Generate Scan Report
## Scan Results
- ESLint violations: 247 (189 auto-fixable)
- Prettier violations: 147 files
- TypeScript issues: 67
- Naming violations: 89
- Organization issues: 568. Store Scan Results
npx claude-flow@alpha hooks post-edit \
--file "style-scan-report.json" \
--memory-key "swarm/code-analyzer/scan-results"Success Criteria
- Complete codebase scanned
- All violation types identified
- Auto-fixable issues flagged
- Report generated
---
Phase 2: Compare to Standards (5 minutes)
Agent: reviewer
Purpose: Compare violations against project coding standards and best practices.
Steps
1. Initialize Standards Comparison
npx claude-flow@alpha hooks pre-task \
--agent-id "reviewer" \
--description "Compare violations to coding standards"2. Load Project Standards
- ESLint config (.eslintrc.json)
- Prettier config (.prettierrc.json)
- TypeScript config (tsconfig.json)
- Custom naming conventions (docs/coding-standards.md)
3. Compare ESLint Configuration
- Configured rules: 178 / 247 (72.1%)
- Base standard: Airbnb
- Missing critical rules: 7
- Conflicting rules: 3
- Disabled important rules: 5
4. Compare Prettier Configuration
- Configuration completeness: 88.9%
- Differences from recommended:
- singleQuote: false → true
- printWidth: 80 → 100
5. Assess TypeScript Strictness
- Strict mode: Disabled
- Individual strict checks: 3/7 enabled (42.9%)
- Recommendations: Enable "strict": true
6. Generate Comparison Report
## Standards Comparison
- ESLint compliance: 72.1%
- Prettier compliance: 88.9%
- TypeScript strictness: 42.9%
- Naming conventions documented: Yes7. Store Comparison Results
npx claude-flow@alpha hooks post-edit \
--file "standards-comparison-report.json" \
--memory-key "swarm/reviewer/standards-comparison"Success Criteria
- Standards documented
- Comparison complete
- Gaps identified
- Recommendations generated
---
Phase 3: Report Violations (5 minutes)
Agent: code-analyzer
Purpose: Generate comprehensive violation reports with prioritization and fix recommendations.
Steps
1. Initialize Violation Reporting
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Generate violation reports"2. Prioritize Violations
- P0 (Critical): 0 - Security risks, breaking issues
- P1 (High): 34 - Potential bugs, code smells
- P2 (Medium): 73 - Best practices
- P3 (Low): 140 - Formatting, style
3. Categorize by File
Top 5 Worst Files:
1. src/api/order-processor.js: 45 violations
2. src/utils/data-transformer.js: 38 violations
3. src/api/user-controller.js: 32 violations
4. src/services/payment.js: 28 violations
5. src/utils/validator.js: 24 violations4. Generate Fix Recommendations
- Auto-fixable: 189 (76.5%)
- Semi-auto-fixable: 23 (9.3%)
- Manual fix required: 35 (14.2%)
5. Create Violation Report
## Violations Report
### Top 10 Rules Violated
1. indent: 67 (P3, auto-fixable)
2. no-unused-vars: 34 (P1, manual)
3. prefer-const: 28 (P2, auto-fixable)
4. no-console: 23 (P1, manual)
5. quotes: 19 (P3, auto-fixable)
### Auto-Fix Commandnpx eslint . --fix npx prettier --write "*/.{js,ts,jsx,tsx}"
6. Export Multi-Format Reports
- JSON (for CI/CD)
- Markdown (for documentation)
- HTML (for viewing)
- CSV (for analysis)
7. Store Violation Reports
npx claude-flow@alpha hooks post-edit \
--file "style-violations-report.json" \
--memory-key "swarm/code-analyzer/violations-report"Success Criteria
- All violations reported
- Violations prioritized
- Fix recommendations generated
- Multi-format exports created
---
Phase 4: Auto-Fix Issues (5 minutes)
Agent: code-analyzer
Purpose: Apply automated fixes for style violations safely.
Steps
1. Initialize Auto-Fix
npx claude-flow@alpha hooks pre-task \
--agent-id "code-analyzer" \
--description "Apply automated style fixes"2. Create Backup
# Backup before applying fixes
BACKUP_DIR="style-audit-backup-$(date +%Y%m%d-%H%M%S)"
git diff --name-only | xargs -I {} cp --parents {} "$BACKUP_DIR/"3. Apply ESLint Auto-Fixes
# Fix all auto-fixable issues
npx eslint . --fix --ext .js,.jsx,.ts,.tsx
# Count fixed issues
FIXED_COUNT=$(jq '[.[] | .messages | .[] | select(.fix)] | length' eslint-fix-results.json)
echo "ESLint fixed: $FIXED_COUNT issues"4. Apply Prettier Formatting
# Format all files
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}"
# Count formatted files
FORMATTED_COUNT=$(grep -c "✅" prettier-fix-log.txt)
echo "Prettier formatted: $FORMATTED_COUNT files"5. Apply TypeScript Fixes
# Limited TypeScript auto-fixes
# Most require manual intervention6. Apply Safe Naming Fixes
// Only apply if no breaking changes
// File renames with reference updates7. Verify Fixes
# Run linting again
npx eslint . --format json > eslint-post-fix.json
# Run tests
npm test8. Generate Fix Report
## Auto-Fix Results
- ESLint fixes: 189
- Prettier formatting: 147 files
- Remaining manual: 58
- Tests: All passing ✅9. Store Fix Results
npx claude-flow@alpha hooks post-edit \
--file "auto-fix-report.json" \
--memory-key "swarm/code-analyzer/auto-fix-results"Success Criteria
- Backup created
- Auto-fixes applied
- Tests pass
- No regressions
---
Phase 5: Validate Compliance (2 minutes)
Agent: reviewer
Purpose: Verify fixes and confirm adherence to coding standards.
Steps
1. Initialize Compliance Validation
npx claude-flow@alpha hooks pre-task \
--agent-id "reviewer" \
--description "Validate style compliance"2. Run Comprehensive Linting
# ESLint validation
npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0
# Prettier validation
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
# TypeScript validation
npx tsc --noEmit --strict3. Calculate Compliance Metrics
ESLint Compliance: 95.8%
Prettier Compliance: 100%
TypeScript Compliance: 76.4%
Naming Conventions: 89.2%
Overall Compliance: 91.2% ✅4. Run Test Suite
# Verify no regressions
npm run test:all -- --coverage5. Validate Build
# Ensure project builds
npm run build6. Generate Compliance Report
## Compliance Validation
### Overall: 91.2% ✅ (Threshold: 90%)
### By Category
- ESLint: 95.8% ✅
- Prettier: 100% ✅
- TypeScript: 76.4% ⚠️
- Naming: 89.2% ⚠️
### Test Results
- Unit: 342/342 ✅
- Integration: 89/89 ✅
- E2E: 42/42 ✅
### Build: ✅ Success7. Store Compliance Results
npx claude-flow@alpha hooks post-edit \
--file "compliance-validation-report.json" \
--memory-key "swarm/reviewer/compliance-validation"8. Commit Fixed Changes
git add .
git commit -m "style: Apply automated style fixes
- ESLint auto-fixes: 189 issues
- Prettier formatting: 147 files
- Remaining manual: 58 issues
- Compliance: 91.2%"Success Criteria
- Overall compliance ≥90%
- All tests passing
- Build successful
- No regressions
---
Final Session Cleanup
# Export audit session
npx claude-flow@alpha hooks session-end \
--session-id "style-audit-${AUDIT_ID}" \
--export-metrics true \
--export-path "./style-audit-summary.json"
# Notify completion
npx claude-flow@alpha hooks notify \
--message "Style audit complete: ${COMPLIANCE_PCT}% compliance"---
Workflow Diagram
┌─────────────────────────────────┐
│ Code Style Audit Workflow │
└─────────────────────────────────┘
│
┌──────────┴──────────┐
│ Phase 1: Scan │
│ Codebase │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ ESLint │
│ Prettier │
│ TypeScript │
│ Naming │
│ Organization │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Phase 2: Compare │
│ to Standards │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Gap Analysis │
│ Recommendations │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Phase 3: Report │
│ Violations │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Prioritize (P0-P3) │
│ Categorize by File │
│ Fix Recommendations│
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Phase 4: Auto-Fix │
│ Issues │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Backup │
│ ESLint --fix │
│ Prettier --write │
│ Verify & Test │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Phase 5: Validate │
│ Compliance │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Calculate Metrics │
│ Run Tests │
│ Validate Build │
└──────────┬──────────┘
│
┌─────┴─────┐
│ │
▼ ▼
┌─────────┐ ┌─────────┐
│ ≥90% │ │ <90% │
│ PASS ✅ │ │ FAIL ⚠️ │
└─────────┘ └─────────┘---
Real-World Example
Scenario: Legacy Codebase Style Cleanup
Codebase Details:
- 247 JavaScript/TypeScript files
- 45,000 lines of code
- No consistent style enforcement
Audit Execution:
npm run style:auditResults After 25 Minutes:
{
"total_violations_found": 247,
"violations_auto_fixed": 189,
"violations_remaining": 58,
"compliance_before": 61.3,
"compliance_after": 91.2,
"improvement": 29.9,
"auto_fix_success_rate": 76.5
}Breakdown:
- ESLint fixes: 189 (indent, quotes, semi, prefer-const, etc.)
- Prettier formatting: 147 files
- Manual fixes needed: 58 (no-unused-vars, no-console)
- Tests: All passing ✅
- Build: Success ✅
Outcome: Style compliance improved from 61.3% to 91.2% with zero regressions.
---
Best Practices
1. Run Regularly: Schedule weekly style audits 2. Auto-Fix First: Apply automated fixes before manual review 3. Prioritize P0/P1: Address high-priority violations immediately 4. Track Trends: Monitor compliance over time 5. Enforce in CI: Block merges below compliance threshold 6. Document Standards: Keep coding standards up-to-date 7. Educate Team: Share style guide with all developers
---
Integration with CI/CD
GitHub Actions Example
name: Style Audit
on: [push, pull_request]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Dependencies
run: npm ci
- name: Run Style Audit
run: npm run style:audit
- name: Check Compliance
run: |
COMPLIANCE=$(jq '.overall_compliance_pct' style-audit-summary.json)
echo "Style Compliance: $COMPLIANCE%"
if [ "$COMPLIANCE" -lt 90 ]; then
echo "Style compliance below 90% threshold"
exit 1
fi
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v3
with:
name: style-audit-reports
path: |
compliance-validation-report.md
style-violations-report.md
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const summary = JSON.parse(fs.readFileSync('style-audit-summary.json'));
const body = `## Style Audit Results\n\n**Compliance:** ${summary.overall_compliance_pct}%\n**Violations Fixed:** ${summary.violations_auto_fixed}\n**Remaining:** ${summary.violations_remaining}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});---
Related Skills
code-review-assistant- Comprehensive PR reviewverification-quality- Quality verificationproduction-readiness- Deployment validation
Code Style Audit with Auto-Fix
Comprehensive code style and conventions audit with automated fix capabilities for consistent code quality.
Quick Start
# Run complete style audit with auto-fix
npm run style:audit
# View results
cat compliance-validation-report.md
# Check compliance score
jq '.overall_compliance_pct' style-audit-summary.jsonWhat This Skill Does
Executes 5-phase style audit: 1. Scan Codebase: Identify all style violations (ESLint, Prettier, TypeScript, naming) 2. Compare to Standards: Validate against project coding standards 3. Report Violations: Generate prioritized violation reports 4. Auto-Fix Issues: Apply automated corrections (76%+ auto-fixable) 5. Validate Compliance: Verify fixes and calculate compliance metrics
Agents Used
- code-analyzer: Scanning, auto-fixing, compliance validation
- reviewer: Standards comparison, manual fix recommendations
Output Files
eslint-report.json- ESLint violationsprettier-violations.txt- Formatting issuestypescript-strict-errors.txt- Type errorsnaming-violations.json- Naming convention issuesstandards-comparison-report.json- Standards gap analysisstyle-violations-report.md- Comprehensive violation reportauto-fix-report.json- Auto-fix resultscompliance-validation-report.md- Final compliance reportstyle-audit-summary.json- Metrics summary
Auto-Fix Capabilities
ESLint (76.5% auto-fixable)
- Indentation (spaces/tabs)
- Quotes (single/double)
- Semicolons
- Trailing commas
- Unused imports
- Var → let/const conversion
Prettier (100% auto-fixable)
- All formatting issues
- Line length
- Bracket spacing
- Arrow function parens
Manual Fixes Required
- Unused variables
- Console statements
- Variable shadowing
- Type errors (TypeScript)
Compliance Score
Overall Compliance = (
ESLint Compliance × 0.50 +
Prettier Compliance × 0.30 +
TypeScript Compliance × 0.20
)
Passing: ≥90% complianceUsage
CLI Commands
# Full audit with auto-fix
npm run style:audit
# Individual phases
npm run style:scan
npm run style:compare-standards
npm run style:report
npm run style:auto-fix
npm run style:validate
# Dry run (no changes)
npm run style:audit -- --dry-runCI/CD Integration
- name: Style Audit
run: npm run style:audit
- name: Check Compliance
run: |
COMPLIANCE=$(jq '.overall_compliance_pct' style-audit-summary.json)
if [ "$COMPLIANCE" -lt 90 ]; then exit 1; fiConfiguration
// style-audit.config.js
module.exports = {
compliance_threshold: 90,
auto_fix: true,
backup_before_fix: true,
standards: {
eslint: '.eslintrc.json',
prettier: '.prettierrc.json',
typescript: 'tsconfig.json'
},
naming_conventions: {
files: 'kebab-case',
classes: 'PascalCase',
functions: 'camelCase',
constants: 'UPPER_SNAKE_CASE'
}
};Violation Priority
| Priority | Description | Examples |
|---|---|---|
| P0 (Critical) | Security risks, breaking issues | no-eval, no-script-url |
| P1 (High) | Potential bugs, code smells | no-unused-vars, no-unreachable |
| P2 (Medium) | Best practices | prefer-const, eqeqeq |
| P3 (Low) | Formatting, style | indent, quotes |
Best Practices
1. Run style audit on every PR 2. Apply auto-fixes before manual review 3. Address P0/P1 violations immediately 4. Track compliance trends over time 5. Enforce style gates in CI/CD 6. Keep configuration standards documented
Related Skills
code-review-assistant- Comprehensive PR reviewverification-quality- Quality verificationproduction-readiness- Deployment readiness
{
"schema_version": "2.0",
"meta": {
"generated_at": "2026-01-17T03:09:16.349Z",
"slug": "dnyoussef-when-auditing-code-style-use-style-audit",
"source_url": "https://github.com/DNYoussef/ai-chrome-extension/tree/main/.claude/skills/testing-quality/when-auditing-code-style-use-style-audit",
"source_ref": "main",
"model": "claude",
"analysis_version": "3.0.0",
"source_type": "community",
"content_hash": "458d8b55bb4c9246bdf891915d2cdd2c39a90cbca7626c22c85b6285ae4f3c6f",
"tree_hash": "dee6ebc96d6f5d34106e621d21eb33d7191636431b8e1ca324ec396a4c3aa4eb"
},
"skill": {
"name": "when-auditing-code-style-use-style-audit",
"description": "Code style and conventions audit with auto-fix capabilities for comprehensive style enforcement",
"summary": "Code style and conventions audit with auto-fix capabilities for comprehensive style enforcement",
"icon": "palette",
"version": "1.0.0",
"author": "DNYoussef",
"license": "MIT",
"category": "testing-quality",
"tags": [
"code quality",
"style enforcement",
"linting",
"formatting",
"compliance"
],
"supported_tools": [
"claude",
"codex",
"claude-code"
],
"risk_factors": [
"scripts",
"external_commands",
"filesystem"
]
},
"security_audit": {
"risk_level": "low",
"is_blocked": false,
"safe_to_publish": true,
"summary": "This is a legitimate code quality tool using standard development tools (ESLint, Prettier, TypeScript). All 369 static findings are FALSE POSITIVES - they are documentation examples showing shell command syntax, not actual malicious code. The skill runs standard linting operations, creates backups before auto-fix, and validates with tests. No network calls to suspicious endpoints. No credential access. No data exfiltration patterns.",
"risk_factor_evidence": [
{
"factor": "scripts",
"evidence": [
{
"file": "PROCESS.md",
"line_start": 44,
"line_end": 90
},
{
"file": "README.md",
"line_start": 7,
"line_end": 16
},
{
"file": "SKILL.md",
"line_start": 44,
"line_end": 90
}
]
},
{
"factor": "external_commands",
"evidence": [
{
"file": "PROCESS.md",
"line_start": 57,
"line_end": 71
},
{
"file": "PROCESS.md",
"line_start": 906,
"line_end": 917
}
]
},
{
"factor": "filesystem",
"evidence": [
{
"file": "PROCESS.md",
"line_start": 215,
"line_end": 226
},
{
"file": "PROCESS.md",
"line_start": 891,
"line_end": 904
}
]
}
],
"critical_findings": [],
"high_findings": [],
"medium_findings": [],
"low_findings": [],
"dangerous_patterns": [],
"files_scanned": 5,
"total_lines": 2668,
"audit_model": "claude",
"audited_at": "2026-01-17T03:09:16.348Z"
},
"content": {
"user_title": "Audit and Fix Code Style Issues",
"value_statement": "Manual code style reviews are time-consuming and inconsistent. This skill automates comprehensive style auditing across ESLint, Prettier, and TypeScript with auto-fix capabilities that apply 76% of fixes automatically.",
"seo_keywords": [
"code style audit",
"ESLint auto-fix",
"Prettier formatting",
"code quality",
"linting automation",
"style compliance",
"Claude Code",
"Claude",
"Codex",
"formatting enforcement"
],
"actual_capabilities": [
"Scan codebase for ESLint, Prettier, and TypeScript violations",
"Compare violations against project coding standards",
"Prioritize violations by severity (P0-P3)",
"Auto-fix 76% of issues automatically",
"Generate compliance reports in JSON, Markdown, HTML, and CSV",
"Validate fixes with tests and build verification"
],
"limitations": [
"Only supports JavaScript, TypeScript, JSON, CSS, and Markdown files",
"Some violations require manual review (unused variables, console statements)",
"Naming convention fixes need reference updates across codebase",
"TypeScript strictness issues mostly require manual intervention"
],
"use_cases": [
{
"target_user": "Development teams",
"title": "PR Style Gate",
"description": "Enforce code style consistency on every pull request before merge"
},
{
"target_user": "Tech leads",
"title": "Legacy Code Cleanup",
"description": "Automatically improve style compliance across large codebases by 30%"
},
{
"target_user": "CI/CD engineers",
"title": "Automated Compliance",
"description": "Integrate style validation into CI pipelines with 90% compliance threshold"
}
],
"prompt_templates": [
{
"title": "Quick Audit",
"scenario": "Run a fast style check",
"prompt": "Run style-audit to scan for violations and generate a violation report"
},
{
"title": "Auto-Fix Run",
"scenario": "Apply automatic fixes",
"prompt": "Use style-audit to scan and auto-fix all ESLint and Prettier violations"
},
{
"title": "Full Compliance",
"scenario": "Complete audit with validation",
"prompt": "Run style-audit with full workflow: scan, compare standards, report, auto-fix, and validate compliance"
},
{
"title": "CI Integration",
"scenario": "CI pipeline compliance check",
"prompt": "Run style-audit and validate that compliance meets 90% threshold, failing the build if below"
}
],
"output_examples": [
{
"input": "Run style-audit with auto-fix on the current codebase",
"output": [
"Style Audit Complete: 91.2% compliance",
"ESLint violations: 247 found, 189 auto-fixed",
"Prettier formatting: 147 files formatted",
"TypeScript issues: 67 (mostly manual)",
"Tests: All 473 passing",
"Backup: style-audit-backup-20250130-143022/",
"Next steps: Address 58 manual violations"
]
},
{
"input": "Check style compliance for a new pull request",
"output": [
"PR Style Check Results",
"Overall Compliance: 94.5% (PASS)",
"New violations: 12 (8 auto-fixable)",
"Auto-fixed: 8 issues",
"Manual review needed: 4 issues",
"Files changed: 8",
"Status: Ready for merge"
]
},
{
"input": "Run compliance validation in CI pipeline",
"output": [
"CI Style Gate: PASSED",
"ESLint Compliance: 96.2%",
"Prettier Compliance: 100%",
"TypeScript Compliance: 82.1%",
"Overall: 93.4% (threshold: 90%)",
"Build can proceed"
]
}
],
"best_practices": [
"Run style audit on every pull request to catch violations early",
"Apply auto-fixes first, then manually address remaining issues",
"Set compliance threshold at 90% for pass/fail gates in CI",
"Keep coding standards documented and version controlled"
],
"anti_patterns": [
"Ignoring P0 critical violations (security rules like no-eval)",
"Running auto-fix without creating a backup first",
"Skipping test validation after applying fixes",
"Setting compliance threshold too low (below 80%)"
],
"faq": [
{
"question": "What file types does this skill support?",
"answer": "JavaScript, TypeScript, JSX, TSX, JSON, CSS, Markdown, YAML, and SCSS files"
},
{
"question": "What is the compliance threshold?",
"answer": "Default threshold is 90%. Fails if compliance drops below this value in CI/CD"
},
{
"question": "How does it integrate with CI/CD?",
"answer": "Add npm run style:audit to your pipeline. Check compliance in style-audit-summary.json"
},
{
"question": "Is my data safe during auto-fix?",
"answer": "Yes. Creates timestamped backup before fixes. Can rollback with git restore if issues occur"
},
{
"question": "What violations require manual fixes?",
"answer": "Unused variables, console statements, variable shadowing, and TypeScript type errors"
},
{
"question": "How does this compare to running eslint directly?",
"answer": "Combines ESLint, Prettier, TypeScript checks with standards comparison, auto-fix workflow, and compliance validation"
}
]
},
"file_structure": [
{
"name": "process-diagram.gv",
"type": "file",
"path": "process-diagram.gv",
"lines": 237
},
{
"name": "PROCESS.md",
"type": "file",
"path": "PROCESS.md",
"lines": 615
},
{
"name": "README.md",
"type": "file",
"path": "README.md",
"lines": 153
},
{
"name": "SKILL.md",
"type": "file",
"path": "SKILL.md",
"lines": 1411
}
]
}
Related skills
FAQ
What tools does it run?
ESLint, Prettier, and TypeScript strict checks, plus naming-convention and file-organization analysis.
Will it break my code?
No, it only applies safe, non-destructive fixes.