JSPM

  • Created
  • Published
  • Downloads 1529
  • Score
    100M100P100Q125281F
  • License MIT

Detects consistency issues in naming, patterns, and architecture that confuse AI models

Package Exports

  • @aiready/consistency

Readme

@aiready/consistency

Detect consistency issues in naming, patterns, and architecture that confuse AI models

Helps teams maintain consistent coding practices across their codebase, making it easier for AI tools to understand and work with your code.

πŸ›οΈ Architecture

                    🎯 USER
                      β”‚
                      β–Ό
            πŸŽ›οΈ  CLI (orchestrator)
                      β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                                   β”‚
    β–Ό                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚πŸŽ¨ VIS- β”‚                        β”‚ ANALY- β”‚
β”‚UALIZER β”‚                        β”‚  SIS   β”‚
β”‚βœ… Readyβ”‚                        β”‚ SPOKES β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
    β”‚                                 β”‚
    β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚           β–Ό                     β–Ό                     β–Ό
    β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚     β”‚πŸ“Š PAT- β”‚           β”‚πŸ“¦ CON- β”‚           β”‚πŸ”§ CON- β”‚
    β”‚     β”‚TERN    β”‚           β”‚TEXT    β”‚           β”‚SISTENCYβ”‚
    β”‚     β”‚DETECT  β”‚           β”‚ANALYZERβ”‚           β”‚        β”‚
    β”‚     β”‚        β”‚           β”‚        β”‚           β”‚        β”‚
    β”‚     β”‚βœ… Readyβ”‚           β”‚βœ… Readyβ”‚           β”‚βœ… Readyβ”‚
    β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚                                                       β”‚
    β”‚                                  ← YOU ARE HERE β”€β”€β”€β”€β”€β”€β”˜
    β”‚                                                       β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                  🏒 HUB (@aiready/core)

🌍 Language Support

Currently Supported (64% market coverage):

  • βœ… TypeScript (.ts, .tsx) - camelCase, PascalCase conventions
  • βœ… JavaScript (.js, .jsx) - camelCase, PascalCase conventions
  • βœ… Python (.py) - PEP 8 conventions (snake_case, PascalCase, UPPER_CASE)

Roadmap:

  • πŸ”œ Java (Q3 2026) - Java naming conventions, JavaBean patterns
  • πŸ”œ Go (Q4 2026) - Go naming conventions, exported names
  • πŸ”œ Rust (Q4 2026) - Rust naming conventions, snake_case
  • πŸ”œ C# (Q1 2027) - C# conventions, PascalCase

πŸš€ Quick Start

Zero config, works out of the box:

# Run without installation (recommended)
npx @aiready/consistency ./src

# Or use the unified CLI (includes all AIReady tools)
npx @aiready/cli scan ./src

# Or install globally for simpler command and faster runs
npm install -g @aiready/consistency
aiready-consistency ./src

🎯 Input & Output

Input: Path to your source code directory

aiready-consistency ./src

Output: Terminal report + optional JSON file (saved to .aiready/ directory)

πŸ“Š Consistency Analysis
━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“ Files analyzed: 47
⚠️  Issues found: 15 naming + 8 pattern issues

CRITICAL (2 files)
  src/utils/helpers.ts:12 - poor-naming: x
  src/api/users.ts:45 - convention-mix: user_name

✨ Smart Defaults (Zero Config)

  • βœ… Auto-excludes test files (**/*.test.*, **/*.spec.*, **/__tests__/**)
  • βœ… Auto-excludes build outputs (dist/, build/, .next/)
  • βœ… Auto-excludes dependencies (node_modules/)
  • βœ… Context-aware: Skips common iterators (i, j, k) in loops
  • βœ… 100+ built-in acceptable abbreviations (env, api, url, ctx, etc.)
  • βœ… Smart detection: Recognizes arrow functions, factory patterns, callbacks

Override defaults with --include-tests or --exclude <patterns> as needed

🎯 What It Does

Inconsistent code patterns confuse AI models and reduce their effectiveness. This tool analyzes:

πŸ”§ Language Support

Fully Supported:

  • TypeScript (.ts, .tsx)
  • JavaScript (.js, .jsx)

Not Yet Supported:

  • Python (.py) - Files will be skipped
  • Java (.java) - Files will be skipped
  • Other languages - Files will be skipped

If you see "Failed to parse" warnings for non-JS/TS files, this is expected behavior and won't affect the analysis of your JavaScript/TypeScript code.

🏷️ Naming Quality & Conventions

  • Single-letter variables - Detects unclear variable names (skips common iterators: i, j, k, l, x, y, z in appropriate contexts)
  • Abbreviations - Identifies unclear abbreviations while allowing 60+ standard ones (env, req, res, ctx, max, min, etc.)
  • Mixed naming conventions - Detects snake_case in TypeScript/JavaScript projects (should use camelCase)
  • Boolean naming - Ensures booleans use clear prefixes (is/has/can/should)
  • Function naming - Checks for action verbs while allowing factory patterns and descriptive names

Smart Detection: The tool understands context and won't flag:

  • Common abbreviations (env, api, url, max, min, now, etc.) - 100+ built-in
  • Boolean prefixes (is, has, can used as variables)
  • Loop iterators (i, j, k) in appropriate contexts
  • Arrow function parameters in callbacks (.map(s => ...))
  • Multi-line arrow functions (detects across 3-5 line context)
  • Short-lived comparison variables (used within 5 lines)
  • Factory/builder patterns
  • Long descriptive function names
  • Project-specific abbreviations via configuration

πŸ”„ Pattern Consistency

  • Error handling strategies - Detects mixed approaches (try-catch vs returns vs throws)
  • Async patterns - Identifies mixing of async/await, promises, and callbacks
  • Import styles - Flags mixing of ES modules and CommonJS
  • API design patterns - Ensures consistent patterns across endpoints

πŸ—οΈ Architectural Consistency (coming soon)

  • File organization patterns
  • Module structure
  • Export/import patterns

πŸ“Š Example Output

πŸ“Š Summary

Files Analyzed: 47
Total Issues: 23
  Naming: 15
  Patterns: 8
  Architecture: 0

🏷️  Naming Issues

MINOR src/utils/helpers.ts:12
  poor-naming: x
  β†’ Use descriptive variable name instead of single letter 'x'

MINOR src/components/User.ts:45
  convention-mix: user_name
  β†’ Use camelCase 'userName' instead of snake_case in TypeScript/JavaScript

πŸ”„ Pattern Issues

MAJOR multiple files
  Inconsistent error handling strategies across codebase
  β†’ Standardize error handling strategy (prefer try-catch with typed errors)

πŸ’‘ Recommendations

1. Standardize naming conventions: Found 7 snake_case variables in TypeScript
2. Improve variable naming: Found 8 single-letter or unclear variable names
3. Use async/await consistently instead of mixing with promise chains

βš™οΈ Usage

# Full analysis
aiready-consistency ./src

# Skip naming checks
aiready-consistency ./src --no-naming

# Skip pattern checks
aiready-consistency ./src --no-patterns

# Show only major issues
aiready-consistency ./src --min-severity major

# Export to JSON (saved to .aiready/ by default)
aiready-consistency ./src --output json

# Export to Markdown (saved to .aiready/ by default)
aiready-consistency ./src --output markdown

# Or specify custom paths
aiready-consistency ./src --output json --output-file custom-report.json
aiready-consistency ./src --output markdown --output-file custom-report.md

πŸ“ Output Files: By default, all output files are saved to the .aiready/ directory in your project root with timestamped filenames. You can override this with --output-file.

πŸŽ›οΈ Options

Option Description Default
--naming Enable naming analysis true
--no-naming Skip naming analysis -
--patterns Enable pattern analysis true
--no-patterns Skip pattern analysis -
--min-severity Minimum severity: info|minor|major|critical info
--include File patterns to include All files
--exclude File patterns to exclude -
--output Output format: console|json|markdown console
--output-file Output file path -

πŸ“ Configuration File

Create .airreadyrc.json, aiready.json, or aiready.config.json in your project root:

{
  "scan": {
    "include": ["src/**/*.{ts,tsx,js,jsx}"],
    "exclude": ["**/dist/**", "**/node_modules/**"]
  },
  "tools": {
    "consistency": {
      "checkNaming": true,
      "checkPatterns": true,
      "minSeverity": "minor",
      "acceptedAbbreviations": ["ses", "gst", "cdk"],
      "shortWords": ["oak", "elm"],
      "disableChecks": []
    }
  },
  "output": {
    "format": "console"
  }
}

Configuration Options:

Option Type Default Description
checkNaming boolean true Check naming conventions
checkPatterns boolean true Check code pattern consistency
minSeverity string 'info' Filter: 'info', 'minor', 'major', 'critical'
acceptedAbbreviations string[] [] Custom abbreviations to accept (e.g., domain-specific terms)
shortWords string[] [] Additional full English words to accept
disableChecks string[] [] Disable specific checks: 'single-letter', 'abbreviation', 'convention-mix', 'unclear', 'poor-naming'

Project-Specific Configuration Examples

React/Next.js Projects:

{
  "tools": {
    "consistency": {
      "acceptedAbbreviations": ["jsx", "tsx", "ref", "ctx", "req", "res"]
    }
  }
}

AWS/Cloud Projects:

{
  "tools": {
    "consistency": {
      "acceptedAbbreviations": ["ses", "sns", "sqs", "ec2", "vpc", "iam"]
    }
  }
}

E-commerce Projects:

{
  "tools": {
    "consistency": {
      "acceptedAbbreviations": ["gst", "vat", "sku", "upc"],
      "shortWords": ["tax", "buy", "pay", "cart"]
    }
  }
}

Acceptable Abbreviations

The tool recognizes 100+ standard abbreviations and won't flag them:

Web/Network: url, uri, api, cdn, dns, ip, http, utm, seo, xhr, cors, ws, wss
Data: json, xml, yaml, csv, html, css, svg, pdf, dto, dao
System: env, os, fs, cli, tmp, src, dst, bin, lib, pkg
Request/Response: req, res, ctx, err, msg
Math: max, min, avg, sum, abs, cos, sin, log, sqrt
Time: now, utc, ms, sec, hr, yr, mo
Loop Counters: i, j, k, n, m
Cloud/Infrastructure: s3, ec2, sqs, sns, vpc, ami, iam, aws
Common: id, uid, db, sql, orm, ui, ux, dom, ref, val, str, obj, arr, cfg, init

See naming.ts for the complete list.

πŸ”§ Programmatic API

import { analyzeConsistency } from '@aiready/consistency';

const report = await analyzeConsistency({
  rootDir: './src',
  checkNaming: true,
  checkPatterns: true,
  minSeverity: 'minor'
});

console.log(`Found ${report.summary.totalIssues} issues`);

🀝 Why This Matters for AI

AI models work best with consistent codebases because:

  1. Pattern Recognition: Consistent patterns help AI understand your coding style
  2. Context Efficiency: Less variation = more useful code fits in context window
  3. Accurate Suggestions: AI can predict conventions and follow them
  4. Reduced Errors: AI makes fewer mistakes with clear, consistent patterns

πŸ“¦ Integration with AIReady

This tool is part of the AIReady ecosystem:

Related packages:

πŸ“– Documentation

🌐 Visit Our Website

Try AIReady tools online and maintain code consistency: getaiready.dev

πŸ“„ License

MIT Β© AIReady Team