@aiready/pattern-detect 0.7.9 → 0.7.12

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/README.md CHANGED
@@ -2,505 +2,158 @@
2
2
 
3
3
  > **Semantic duplicate pattern detection for AI-generated code**
4
4
 
5
- When AI tools generate code without awareness of existing patterns in your codebase, you end up with semantically similar but syntactically different implementations. This tool finds those patterns and quantifies their cost.
5
+ Finds semantically similar but syntactically different code patterns that waste AI context and confuse models.
6
6
 
7
- ## 🎯 Why This Tool?
7
+ ## 🚀 Quick Start
8
8
 
9
- ### The AI Code Problem
10
-
11
- AI coding assistants (GitHub Copilot, ChatGPT, Claude) generate functionally similar code in different ways because:
12
- - No awareness of existing patterns in your codebase
13
- - Different AI models have different coding styles
14
- - Team members use AI tools with varying contexts
15
- - AI can't see your full codebase (context window limits)
16
-
17
- ### What Makes Us Different?
18
-
19
- | Feature | jscpd | @aiready/pattern-detect |
20
- |---------|-------|------------------------|
21
- | Detection Method | Byte-level exact matching | Semantic similarity |
22
- | Pattern Types | Generic blocks | Categorized (API, validators, utils, etc.) |
23
- | Token Cost | ❌ No | ✅ Yes - shows AI context waste |
24
- | Refactoring Suggestions | ❌ Generic | ✅ Specific to pattern type |
25
- | Output Formats | Text/JSON | Console/JSON/HTML with rich formatting |
26
-
27
- #### How We Differ (and When to Use Each)
28
-
29
- - **Semantic intent vs exact clones**: jscpd flags copy-paste or near-duplicates; we detect functionally similar code even when structure differs (e.g., two API handlers with different frameworks).
30
- - **Pattern typing**: We classify duplicates into `api-handler`, `validator`, `utility`, `component`, etc., so teams can prioritize coherent refactors.
31
- - **AI context cost**: We estimate tokens wasted to quantify impact on AI tools (larger context, higher cost, more confusion).
32
- - **Refactoring guidance**: We propose targeted fixes per pattern type (e.g., extract middleware or create base handler).
33
- - **Performance profile**: We use Jaccard similarity with candidate filtering; ~2–3s for ~500 blocks on medium repos.
34
-
35
- Recommended workflow:
36
- - Run **jscpd** in CI to enforce low clone percentage (blocking).
37
- - Run **@aiready/pattern-detect** to surface semantic duplicates and token waste (advisory), feeding a refactoring backlog.
38
- - Use both for comprehensive hygiene: jscpd for exact clones; AIReady for intent-level duplication that AI tends to reintroduce.
39
-
40
- ## 🚀 Installation
9
+ **Recommended: Use the unified CLI** (includes pattern detection + more tools):
41
10
 
42
11
  ```bash
43
- npm install -g @aiready/pattern-detect
44
-
45
- # Or use directly with npx
46
- npx @aiready/pattern-detect ./src
12
+ npm install -g @aiready/cli
13
+ aiready patterns ./src
47
14
  ```
48
15
 
49
- ## 📊 Usage
50
-
51
- ### CLI
16
+ **Or use this package directly:**
52
17
 
53
18
  ```bash
54
- # Basic usage
19
+ npm install -g @aiready/pattern-detect
55
20
  aiready-patterns ./src
56
-
57
- # Adjust sensitivity
58
- aiready-patterns ./src --similarity 0.9
59
-
60
- # Only look at larger patterns
61
- aiready-patterns ./src --min-lines 10
62
-
63
- # Filter by severity (focus on critical issues first)
64
- aiready-patterns ./src --severity critical # Only >95% similar
65
- aiready-patterns ./src --severity high # Only >90% similar
66
- aiready-patterns ./src --severity medium # Only >80% similar
67
-
68
- # Include test files (excluded by default)
69
- aiready-patterns ./src --include-tests
70
-
71
- # Memory optimization for large codebases
72
- aiready-patterns ./src --max-blocks 1000 --batch-size 200
73
-
74
- # Export to JSON
75
- aiready-patterns ./src --output json --output-file report.json
76
-
77
- # Generate HTML report
78
- aiready-patterns ./src --output html
79
- ```
80
-
81
- #### Presets (quick copy/paste)
82
-
83
- ```bash
84
- # Speed-first (large repos)
85
- aiready-patterns ./src \
86
- --min-shared-tokens 12 \
87
- --max-candidates 60 \
88
- --max-blocks 300
89
-
90
- # Coverage-first (more findings)
91
- aiready-patterns ./src \
92
- --min-shared-tokens 6 \
93
- --max-candidates 150
94
-
95
- # Short-block focus (helpers/utilities)
96
- aiready-patterns ./src \
97
- --min-lines 5 \
98
- --min-shared-tokens 6 \
99
- --max-candidates 120 \
100
- --exclude "**/test/**"
101
-
102
- # Deep dive with streaming (comprehensive detection)
103
- aiready-patterns ./src \
104
- --no-approx \
105
- --stream-results
106
- ```
107
-
108
- ### Configuration
109
-
110
- Create an `aiready.json` or `aiready.config.json` file in your project root to persist settings:
111
-
112
- ```json
113
- {
114
- "scan": {
115
- "include": ["**/*.{ts,tsx,js,jsx}"],
116
- "exclude": ["**/test/**", "**/*.test.*"]
117
- },
118
- "tools": {
119
- "pattern-detect": {
120
- "minSimilarity": 0.5,
121
- "minLines": 8,
122
- "approx": false,
123
- "batchSize": 200,
124
- "severity": "high",
125
- "includeTests": false
126
- }
127
- }
128
- }
129
21
  ```
130
22
 
131
- CLI options override config file settings.
132
-
133
- ### Programmatic API
23
+ ## 🎯 What It Does
134
24
 
135
- ```typescript
136
- import { analyzePatterns, generateSummary } from '@aiready/pattern-detect';
25
+ AI tools generate similar code in different ways because they lack awareness of your codebase patterns. This tool:
137
26
 
138
- const results = await analyzePatterns({
139
- rootDir: './src',
140
- minSimilarity: 0.85, // 85% similar
141
- minLines: 5,
142
- include: ['**/*.ts', '**/*.tsx'],
143
- exclude: ['**/*.test.ts', '**/node_modules/**'],
144
- });
27
+ - **Semantic detection**: Finds functionally similar code (not just copy-paste)
28
+ - **Pattern classification**: Groups duplicates by type (API handlers, validators, utilities, etc.)
29
+ - **Token cost analysis**: Shows wasted AI context budget
30
+ - **Refactoring guidance**: Suggests specific fixes per pattern type
145
31
 
146
- const summary = generateSummary(results);
32
+ ### Example Output
147
33
 
148
- console.log(`Found ${summary.totalPatterns} duplicate patterns`);
149
- console.log(`Token cost: ${summary.totalTokenCost} tokens wasted`);
150
- console.log(`Pattern breakdown:`, summary.patternsByType);
151
34
  ```
152
-
153
- ## 🔍 Real-World Example
154
-
155
- ### Before Analysis
156
-
157
- Two API handlers that were written by AI on different days:
158
-
159
- ```typescript
160
- // File: src/api/users.ts
161
- app.get('/api/users/:id', async (request, response) => {
162
- const user = await db.users.findOne({ id: request.params.id });
163
- if (!user) {
164
- return response.status(404).json({ error: 'User not found' });
165
- }
166
- response.json(user);
167
- });
168
-
169
- // File: src/api/posts.ts
170
- router.get('/posts/:id', async (req, res) => {
171
- const post = await database.posts.findOne({ id: req.params.id });
172
- if (!post) {
173
- res.status(404).send({ message: 'Post not found' });
174
- return;
175
- }
176
- res.json(post);
177
- });
178
- ```
179
-
180
- ### Analysis Output
181
-
182
- ```
183
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
184
- PATTERN ANALYSIS SUMMARY
185
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
186
-
187
35
  📁 Files analyzed: 47
188
36
  ⚠ Duplicate patterns found: 23
189
37
  💰 Token cost (wasted): 8,450
190
38
 
191
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
192
- PATTERNS BY TYPE
193
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
194
-
195
- 🌐 api-handler 12
196
- ✓ validator 8
197
- 🔧 utility 3
198
-
199
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
200
- TOP DUPLICATE PATTERNS
201
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
39
+ 🌐 api-handler 12 patterns
40
+ validator 8 patterns
41
+ 🔧 utility 3 patterns
202
42
 
203
43
  1. 87% 🌐 api-handler
204
- src/api/users.ts:15
205
- ↔ src/api/posts.ts:22
44
+ src/api/users.ts:15 ↔ src/api/posts.ts:22
206
45
  432 tokens wasted
207
-
208
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
209
- CRITICAL ISSUES (>95% similar)
210
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
211
-
212
- ● src/utils/validators.ts:15
213
- validator pattern 97% similar to src/utils/checks.ts (125 tokens wasted)
214
- → Consolidate validation logic into shared schema validators (Zod/Yup) (CRITICAL: Nearly identical code)
46
+ → Create generic handler function
215
47
  ```
216
48
 
217
- ### Suggested Refactoring
49
+ ## ⚙️ Key Options
218
50
 
219
- Create a generic handler:
51
+ ```bash
52
+ # Basic usage
53
+ aiready patterns ./src
220
54
 
221
- ```typescript
222
- // utils/apiHandler.ts
223
- export const createResourceHandler = (resourceName: string, findFn: Function) => {
224
- return async (req: Request, res: Response) => {
225
- const item = await findFn({ id: req.params.id });
226
- if (!item) {
227
- return res.status(404).json({ error: `${resourceName} not found` });
228
- }
229
- res.json(item);
230
- };
231
- };
55
+ # Focus on obvious duplicates
56
+ aiready patterns ./src --similarity 0.9
232
57
 
233
- // src/api/users.ts
234
- app.get('/api/users/:id', createResourceHandler('User', db.users.findOne));
58
+ # Include smaller patterns
59
+ aiready patterns ./src --min-lines 3
235
60
 
236
- // src/api/posts.ts
237
- router.get('/posts/:id', createResourceHandler('Post', database.posts.findOne));
61
+ # Export results
62
+ aiready patterns ./src --output json --output-file report.json
238
63
  ```
239
64
 
240
- **Result:** Reduced from 432 tokens to ~100 tokens in AI context.
241
-
242
- ## ⚙️ Configuration
65
+ ## 🎛️ Tuning Guide
243
66
 
244
- ### Common Options
67
+ ### Main Parameters
245
68
 
246
- | Option | Description | Default |
247
- |--------|-------------|---------|
248
- | `minSimilarity` | Similarity threshold (0-1). Default `0.40` (Jaccard). Raise for only obvious duplicates; lower to catch more | `0.40` |
249
- | `minSimilarity` | Similarity threshold (0-1). Default `0.40` (Jaccard). Raise for only obvious duplicates; lower to catch more | `0.40` |
250
- | `minLines` | Minimum lines to consider a pattern | `5` |
251
- | `maxBlocks` | Maximum code blocks to analyze (prevents OOM) | `500` |
252
- | `include` | File patterns to include | `['**/*.{ts,tsx,js,jsx,py,java}']` |
253
- | `exclude` | File patterns to exclude | See below |
69
+ | Parameter | Default | Effect | Use When |
70
+ |-----------|---------|--------|----------|
71
+ | `--similarity` | `0.4` | Similarity threshold (0-1) | Want more/less sensitive detection |
72
+ | `--min-lines` | `5` | Minimum lines per pattern | Include/exclude small functions |
73
+ | `--min-shared-tokens` | `8` | Tokens that must match | Control comparison strictness |
254
74
 
255
- ### Exclude Patterns (Default)
75
+ ### Quick Tuning Scenarios
256
76
 
257
- By default, these patterns are excluded:
77
+ **Want more results?** (catch subtle duplicates)
258
78
  ```bash
259
- # Dependencies
260
- **/node_modules/**
261
-
262
- # Build outputs
263
- **/dist/**, **/build/**, **/out/**, **/output/**, **/target/**, **/bin/**, **/obj/**
264
-
265
- # Framework-specific build dirs
266
- **/.next/**, **/.nuxt/**, **/.vuepress/**, **/.cache/**, **/.turbo/**
267
-
268
- # Test and coverage
269
- **/coverage/**, **/.nyc_output/**, **/.jest/**
79
+ # Lower similarity threshold
80
+ aiready patterns ./src --similarity 0.3
270
81
 
271
- # Version control and IDE
272
- **/.git/**, **/.svn/**, **/.hg/**, **/.vscode/**, **/.idea/**, **/*.swp, **/*.swo
82
+ # Include smaller functions
83
+ aiready patterns ./src --min-lines 3
273
84
 
274
- # Build artifacts and minified files
275
- **/*.min.js, **/*.min.css, **/*.bundle.js, **/*.tsbuildinfo
276
-
277
- # Logs and temporary files
278
- **/logs/**, **/*.log, **/.DS_Store
85
+ # Both together
86
+ aiready patterns ./src --similarity 0.3 --min-lines 3
279
87
  ```
280
88
 
281
- Override with `--exclude` flag:
89
+ **Want fewer but higher quality results?** (focus on obvious duplicates)
282
90
  ```bash
283
- # Exclude test files and generated code
284
- aiready-patterns ./src --exclude "**/test/**,**/generated/**,**/__snapshots__/**"
91
+ # Higher similarity threshold
92
+ aiready patterns ./src --similarity 0.8
285
93
 
286
- # Add to defaults (comma-separated)
287
- aiready-patterns ./src --exclude "**/node_modules/**,**/dist/**,**/build/**,**/*.spec.ts"
94
+ # Larger patterns only
95
+ aiready patterns ./src --min-lines 10
288
96
  ```
289
97
 
290
- ## 📈 Understanding the Output
291
-
292
- ### Severity Levels
293
-
294
- - **CRITICAL (>95% similar)**: Nearly identical code - refactor immediately
295
- - **MAJOR (>90% similar)**: Very similar - refactor soon
296
- - **MINOR (>85% similar)**: Similar - consider refactoring
297
-
298
- ### Pattern Types
299
-
300
- - **🌐 api-handler**: REST API endpoints, route handlers
301
- - **✓ validator**: Input validation, schema checks
302
- - **🔧 utility**: Pure utility functions
303
- - **📦 class-method**: Class methods with similar logic
304
- - **⚛️ component**: UI components (React, Vue, etc.)
305
- - **ƒ function**: Generic functions
306
-
307
- ### Token Cost
308
-
309
- Estimated tokens wasted when AI tools process duplicate code:
310
- - Increases context window usage
311
- - Higher API costs for AI-powered tools
312
- - Slower analysis and generation
313
- - More potential for AI confusion
314
-
315
- ## 🎓 Best Practices
316
-
317
- 1. **Run regularly**: Integrate into CI/CD to catch new duplicates early
318
- 2. **Start with high similarity**: Use `--similarity 0.9` to find obvious wins
319
- 3. **Focus on critical issues**: Fix >95% similar patterns first
320
- 4. **Use pattern types**: Prioritize refactoring by category (API handlers → validators → utilities)
321
- 5. **Export reports**: Generate HTML reports for team reviews
322
-
323
- ## ⚠️ Performance & Memory
324
-
325
- ### Algorithm Complexity
326
-
327
- **Jaccard Similarity**: **O(B × C × T)** where:
328
- - B = number of blocks
329
- - C = average candidates per block (~100)
330
- - T = average tokens per block (~50)
331
- - **O(T) per comparison** instead of O(N²)
332
- - **Default threshold: 0.40** (comprehensive detection including tests and helpers)
333
-
334
- ### Performance Benchmarks
335
-
336
- | Repo Size | Blocks | Analysis Time |
337
- |-----------|--------|--------------|
338
- | Small (<100 files) | ~50 | <1s |
339
- | Medium (100-500 files) | ~500 | ~2s |
340
- | Large (500+ files) | ~500 (capped) | ~2s |
341
-
342
- **Example:** 828 code blocks → limited to 500 → **2.4s** analysis time
343
-
344
- ### Tuning Options
345
-
98
+ **Analysis too slow?** (optimize for speed)
346
99
  ```bash
347
- # Default (40% threshold - comprehensive detection)
348
- aiready-patterns ./src
349
-
350
- # Higher threshold for only obvious duplicates
351
- aiready-patterns ./src --similarity 0.65
352
-
353
- # Lower threshold for more potential duplicates
354
- aiready-patterns ./src --similarity 0.55
355
-
356
- # Approximate mode is default (fast, with candidate filtering)
357
- aiready-patterns ./src
358
-
359
- # Exact mode with progress tracking (shows % and ETA)
360
- aiready-patterns ./src --no-approx --stream-results
100
+ # Focus on substantial functions
101
+ aiready patterns ./src --min-lines 10
361
102
 
362
- # Maximum speed (aggressive filtering)
363
- aiready-patterns ./src --min-shared-tokens 12 --min-lines 10
103
+ # Reduce comparison candidates
104
+ aiready patterns ./src --min-shared-tokens 12
364
105
  ```
365
106
 
366
- ## 🎛️ Tuning Playbook
367
-
368
- Use these presets to quickly balance precision, recall, and runtime:
369
-
370
- - Speed-first (large repos):
371
- - `aiready-patterns ./src --min-shared-tokens 12 --max-candidates 60 --max-blocks 300`
372
- - Cuts weak candidates early; best for fast, iterative scans.
373
-
374
- - Coverage-first (more findings):
375
- - `aiready-patterns ./src --min-shared-tokens 6 --max-candidates 150`
376
- - Expands candidate pool; expect more results and longer runtime.
377
-
378
- - Short-block focus (helpers/utilities):
379
- - `aiready-patterns ./src --min-lines 5 --min-shared-tokens 6 --max-candidates 120`
380
- - Better recall for small functions; consider `--exclude "**/test/**"` to reduce noise.
381
-
382
- ### Minimum Lines vs Min Shared Tokens
383
-
384
- - `minLines` filters which blocks are extracted; lower values include smaller functions that have fewer tokens overall.
385
- - Smaller blocks naturally share fewer tokens; to avoid missing true matches when `minLines` is low (≤5–6), consider lowering `minSharedTokens` by 1–2.
386
- - Recommended pairs:
387
- - `minLines 5–6` → `minSharedTokens 6–8` (recall-friendly; watch noise)
388
- - `minLines 8–10` → `minSharedTokens 8–10` (precision-first)
389
- - Default balance: `minLines=5`, `minSharedTokens=8` works well for most repos. Reduce `minSharedTokens` only when you specifically want to catch more short helpers.
390
-
391
- **CLI Options:**
392
- - `--stream-results` - Output duplicates as found (enabled by default)
393
- - `--no-approx` - Disable approximate mode (slower, O(B²) complexity, use with caution)
394
- - `--min-lines N` - Filter blocks smaller than N lines (default 5)
395
-
396
- ### Controlling Analysis Scope
397
-
398
- The tool analyzes **all extracted code blocks** by default. Control scope using:
107
+ ### Parameter Tradeoffs
399
108
 
400
- **1. `--min-lines` (primary filter):**
401
- - Filters blocks during extraction (most efficient)
402
- - Higher values = focus on substantial functions
403
- - Lower values = catch smaller utility duplicates
109
+ | Adjustment | More Results | Faster | Higher Quality | Tradeoff |
110
+ |------------|--------------|--------|----------------|----------|
111
+ | Lower `--similarity` | | | ❌ | More false positives |
112
+ | Lower `--min-lines` | | | ❌ | Includes trivial duplicates |
113
+ | Higher `--similarity` | ❌ | ✅ | ✅ | Misses subtle duplicates |
114
+ | Higher `--min-lines` | ❌ | ✅ | ✅ | Misses small but important patterns |
404
115
 
405
- **2. `--no-approx` mode (use with caution):**
406
- - Disables approximate mode (candidate pre-filtering)
407
- - O(B²) complexity - compares every block to every other block
408
- - **Automatic safety limit:** 500K comparisons (~1000 blocks max)
409
- - Shows warning when used with >500 blocks
410
- - Approximate mode (default) is recommended for all use cases
116
+ ### Common Workflows
411
117
 
412
- **Examples:**
118
+ **First run** (broad discovery):
413
119
  ```bash
414
- # Focus on substantial functions only
415
- aiready-patterns ./src --min-lines 15
416
-
417
- # Comprehensive scan of all functions (recommended)
418
- aiready-patterns ./src --min-lines 5
419
-
420
- # Quick scan of major duplicates
421
- aiready-patterns ./src --min-lines 20
120
+ aiready patterns ./src # Default settings
422
121
  ```
423
122
 
424
- **Recommendations by codebase size:**
425
-
426
- | Repo Size | Files | Strategy | Expected Time |
427
- |-----------|-------|----------|---------------|
428
- | **Small** | <100 | Use defaults | <1s ✅ |
429
- | **Medium** | 100-500 | Use defaults | 1-5s ✅ |
430
- | **Large** | 500-1,000 | Use defaults or `--min-lines 10` | 3-10s ✅ |
431
- | **Very Large** | 1,000-5,000 | `--min-lines 15` or analyze by module | 5-20s ⚠️ |
432
- | **Super Large** | 5,000+ | **Analyze by module** (see below) | 10-60s per module ⚠️ |
433
-
434
- ### Analyzing Very Large Repositories
435
-
436
- For repos with 1,000+ files, use modular analysis:
123
+ **Focus on critical issues** (production ready):
124
+ ```bash
125
+ aiready patterns ./src --similarity 0.8 --min-lines 8
126
+ ```
437
127
 
128
+ **Catch everything** (comprehensive audit):
438
129
  ```bash
439
- # Analyze by top-level directory
440
- for dir in src/*/; do
441
- echo "Analyzing $dir"
442
- aiready-patterns "$dir" --min-lines 10
443
- done
444
-
445
- # Or focus on specific high-value areas
446
- aiready-patterns ./src/api --min-lines 10
447
- aiready-patterns ./src/core --min-lines 10
448
- aiready-patterns ./src/services --min-lines 10
449
-
450
- # For super large repos (5K+ files), increase thresholds
451
- aiready-patterns ./src/backend --min-lines 20 --similarity 0.50
130
+ aiready patterns ./src --similarity 0.3 --min-lines 3
452
131
  ```
453
132
 
454
- **Why modular analysis?**
455
- - Ensures comprehensive coverage (100% of each module)
456
- - Avoids hitting comparison budget limits
457
- - Provides focused, actionable results per module
458
- - Better for CI/CD integration (parallel jobs)
459
-
460
- **Progress Indicators:**
461
- - **Approx mode**: Shows blocks processed + duplicates found
462
- - **Exact mode**: Shows % complete, ETA, and comparisons processed
463
- - **Stream mode**: Prints each duplicate immediately when found (enabled by default)
464
-
465
- ## 🔧 CI/CD Integration
466
-
467
- ### GitHub Actions
468
-
469
- ```yaml
470
- name: Pattern Detection
471
-
472
- on: [pull_request]
473
-
474
- jobs:
475
- detect-patterns:
476
- runs-on: ubuntu-latest
477
- steps:
478
- - uses: actions/checkout@v3
479
- - uses: actions/setup-node@v3
480
- - run: npx @aiready/pattern-detect ./src --output json --output-file patterns.json
481
- - name: Check for critical issues
482
- run: |
483
- CRITICAL=$(jq '.summary.topDuplicates | map(select(.similarity > 0.95)) | length' patterns.json)
484
- if [ "$CRITICAL" -gt "0" ]; then
485
- echo "Found $CRITICAL critical duplicate patterns"
486
- exit 1
487
- fi
133
+ **Performance optimization** (large codebases):
134
+ ```bash
135
+ aiready patterns ./src --min-lines 10 --min-shared-tokens 10
488
136
  ```
489
137
 
490
- ## 🤝 Contributing
138
+ **Use the unified CLI** for all AIReady tools:
491
139
 
492
- We welcome contributions! This tool is part of the [AIReady](https://github.com/aiready/aiready) ecosystem.
140
+ ```bash
141
+ npm install -g @aiready/cli
493
142
 
494
- ## 📝 License
143
+ # Pattern detection
144
+ aiready patterns ./src
495
145
 
496
- MIT - See LICENSE file
146
+ # Context analysis (token costs, fragmentation)
147
+ aiready context ./src
497
148
 
498
- ## 🔗 Related Tools (Coming Soon)
149
+ # Full codebase analysis
150
+ aiready scan ./src
151
+ ```
499
152
 
500
- - **@aiready/context-analyzer** - Analyze token costs and context fragmentation
501
- - **@aiready/doc-drift** - Track documentation freshness
502
- - **@aiready/consistency** - Check naming pattern consistency
153
+ **Individual packages:**
154
+ - [**@aiready/cli**](https://www.npmjs.com/package/@aiready/cli) - Unified CLI with all tools
155
+ - [**@aiready/context-analyzer**](https://www.npmjs.com/package/@aiready/context-analyzer) - Context window cost analysis
503
156
 
504
157
  ---
505
158
 
506
- **Made with 💙 by the AIReady team** | [Docs](https://aiready.dev/docs) | [GitHub](https://github.com/aiready/aiready)
159
+ **Made with 💙 by the AIReady team** | [GitHub](https://github.com/caopengau/aiready)