@nebutra/next-unicorn-skill 1.0.3 → 1.0.4

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/SKILL.md CHANGED
@@ -1,27 +1,15 @@
1
1
  ---
2
2
  name: analyze-and-recommend-third-party-optimizations
3
- description: Scans any codebase and identifies where hand-rolled implementations should be replaced by battle-tested third-party libraries, producing structured migration plans with Context7-verified recommendations
4
- version: 1.0.3
5
- author: TsekaLuk
6
- tags:
7
- - code-analysis
8
- - third-party-libraries
9
- - migration-planning
10
- - dependency-optimization
11
- - context7-verification
12
- - ux-audit
13
- - impact-scoring
14
- - vulnerability-scanning
15
- - auto-update
16
- - pr-automation
3
+ description: >-
4
+ Scan a codebase to identify hand-rolled implementations that should be replaced
5
+ by third-party libraries, and identify missing capabilities the project should
6
+ have. Produce structured migration plans with Context7-verified recommendations.
7
+ Use when analyzing technical debt, auditing dependency health, reviewing
8
+ hand-rolled code, planning library migrations, or assessing capability gaps.
17
9
  ---
18
10
 
19
11
  # Analyze and Recommend Third-Party Optimizations
20
12
 
21
- ## Purpose
22
-
23
- Two-pronged analysis: (1) detect hand-rolled code that should be replaced by libraries, and (2) identify missing capabilities the project should have. The scanner pre-filters; the AI agent provides unicorn-grade recommendations — ecosystem-level solutions with rationale, anti-patterns, and alternatives, verified via Context7 MCP.
24
-
25
13
  ## Architecture
26
14
 
27
15
  ```
@@ -31,82 +19,60 @@ hand-rolled code 2. Identify capability gaps filter, seria
31
19
  using knowledge + Context7
32
20
  ```
33
21
 
34
- **Key principles**:
35
- - No hardcoded library recommendations — the AI agent evaluates project context dynamically
36
- - Two analysis modes: **replacement** (hand-rolled code → library) and **gap** (missing capability library)
22
+ **Design constraints**:
23
+ - No hardcoded library recommendations — evaluate project context dynamically
24
+ - Two analysis modes: **replacement** (hand-rolled code found) and **gap** (capability missing entirely)
37
25
 
38
26
  ## Standard Operating Procedure
39
27
 
40
28
  ### Step 1: Validate Input
41
29
 
42
- Parse and validate `InputSchema` JSON via Zod. Required fields:
43
- - **Project metadata**: repo path, languages, package managers, current libraries
44
- - **Optimization goals**: what the project wants to improve
45
- - **Constraints**: license allowlist, excluded libraries
46
- - **Priority focus areas**: Vibe Coding Domains to prioritize
30
+ Parse and validate `InputSchema` JSON via Zod. Read `src/schemas/input.schema.ts` for the full schema.
47
31
 
48
32
  ### Step 2: Scan Codebase
49
33
 
50
- Run `scanCodebase(input)` to walk the file tree and match against regex patterns. The scanner:
34
+ Run `scanCodebase(input)`. The scanner:
51
35
 
52
- 1. Detects workspace roots for monorepo support
53
- 2. Matches code against 20+ domain patterns (i18n, auth, state-management, etc.)
54
- 3. Records each detection with: file path, line range, pattern category, confidence score, domain
55
- 4. Returns `ScanResult` with detections and workspace info
36
+ 1. Detect workspace roots for monorepo support
37
+ 2. Match code against 20+ domain patterns (i18n, auth, state-management, etc.)
38
+ 3. Record each detection with: file path, line range, pattern category, confidence score, domain
39
+ 4. Return `ScanResult` with detections and workspace info
56
40
 
57
- Detections contain **no library suggestions** — only what was detected and where.
41
+ Detections contain no library suggestions — only what was detected and where.
58
42
 
59
43
  ### Step 2.5: Gap Analysis (AI Agent)
60
44
 
61
- Beyond what the scanner detects (hand-rolled code), analyze what the project is **missing entirely**. Review `currentLibraries`, `languages`, `optimizationGoals`, and `priorityFocusAreas` to identify capability gaps.
62
-
63
- Think at the level of unicorn-grade products:
64
- - "No structured logging" recommend pino + OpenTelemetry ecosystem
65
- - "No error monitoring" recommend Sentry with source maps + release health
66
- - "No event-driven workflows"recommend Inngest for reliable async tasks
67
- - "Using nodemailer" → recommend Resend for modern transactional email
68
- - "No rate limiting or bot protection" → recommend Arcjet as unified security layer
69
- - "REST API without type safety" recommend tRPC for end-to-end types
70
-
71
- Provide each gap as a `GapRecommendation`:
72
- ```typescript
73
- {
74
- domain: string; // e.g., "observability"
75
- description: string; // e.g., "No structured logging detected"
76
- recommendedLibrary: { name, version, license, rationale?, ecosystem?, antiPatterns?, alternatives? };
77
- priority: 'critical' | 'recommended' | 'nice-to-have';
78
- }
79
- ```
45
+ Beyond scanner detections, analyze what the project is **missing entirely**. Inspect:
46
+
47
+ 1. **Installed dependencies** — identify low-level tools that should be upgraded to platform-level solutions
48
+ 2. **Monorepo structure** identify missing architectural layers (e.g., shared token package, shared config preset)
49
+ 3. **Cross-cutting concerns** — identify absent capabilities: structured logging, error monitoring, rate limiting, event-driven workflows, transactional email, type-safe API layer
50
+ 4. **Architecture patterns** — identify opportunities for multi-package solutions (e.g., design-tokens tailwind-config ui three-layer architecture for design systems)
51
+
52
+ Analyze at three levels of depth:
53
+ - **Single library gap**: missing one tool (e.g., no form validation library)
54
+ - **Ecosystem gap**: missing a coordinated set of tools (e.g., no observability stack)
55
+ - **Architecture gap**: missing an entire structural layer (e.g., no design system, no shared config)
80
56
 
81
- Pass gaps to `analyze()` via the `gaps` option. They appear in the output as `gapAnalysis`.
57
+ Provide each gap as a `GapRecommendation`. Read `src/index.ts` for the interface. Pass gaps via the `gaps` option in `analyze()`.
58
+
59
+ **Design system gaps** — Two paths depending on project maturity:
60
+ - **No existing frontend**: Scaffold from reference repos. Read `references/design-system-sources.md` for curated sources and sparse-checkout workflow.
61
+ - **Existing frontend without formal design system**: First extract the spec (audit → tokens → classify → document) via `references/design-system-extraction.md`, then implement the architecture via `references/design-system-sources.md`.
82
62
 
83
63
  ### Step 3: Recommend Solutions (AI Agent)
84
64
 
85
- For each detection, recommend a **solution** — not just a library, but an ecosystem-level answer. Consider:
65
+ For each scanner detection, recommend a **solution**. Consider:
86
66
 
87
67
  1. **Ecosystem composition** — recommend companion libraries that work together
88
- (e.g., `@lingui/core` + `@lingui/macro` + `@lingui/cli` for compile-time i18n with TMS integration)
89
- 2. **Rationale** — explain WHY this specific choice fits this project's framework, runtime, and scale
90
- 3. **Anti-patterns** — what NOT to use and why (e.g., "Never use jsonwebtoken — no edge runtime support; use jose")
68
+ 2. **Rationale** explain WHY this choice fits this project's framework, runtime, and scale
69
+ 3. **Anti-patterns** — what NOT to use and why
91
70
  4. **Alternatives** — different solutions for different architectural contexts
92
71
  5. **Context7 verification** — call `resolve-library-id` + `query-docs` to confirm the library exists and get latest version/docs
93
72
 
94
- Return a `LibraryRecommendation` per detection:
95
- ```typescript
96
- {
97
- library: string; // required — primary package
98
- version: string; // required
99
- license: string; // required
100
- rationale?: string; // recommended — WHY this choice
101
- ecosystem?: Array<{...}>; // when solution involves multiple packages
102
- antiPatterns?: string[]; // when common mistakes exist
103
- alternatives?: Array<{...}>; // when architecture affects the choice
104
- }
105
- ```
106
-
107
- Return `null` to skip a detection (intentional custom code, false positive, etc.).
73
+ Read `src/index.ts` for the `LibraryRecommendation` interface. Return `null` to skip a detection.
108
74
 
109
- **False positive filtering** — skip if:
75
+ **Skip a detection if**:
110
76
  - Code has comments explaining why it is custom
111
77
  - Detection is in test/mock/fixture files
112
78
  - Library is already in project dependencies (suggest version update instead)
@@ -114,15 +80,15 @@ Return `null` to skip a detection (intentional custom code, false positive, etc.
114
80
 
115
81
  ### Step 4: Score Impact
116
82
 
117
- Compute 7-dimension impact scores (scalability, performance, security, maintainability, feature richness, UX, UI aesthetics) with composite score, migration risk, and estimated effort.
83
+ Call `computeImpactScore()` for each detection. Optionally provide `dimensionHints` and `baseEffortHours` for more accurate scoring. Read `src/scorer/impact-scorer.ts` for the interface.
118
84
 
119
85
  ### Step 5: Build Migration Plan
120
86
 
121
- Group recommendations into phases by risk (low medium high), ordered by domain priority (infrastructure first, presentation last). High-risk items include adapter strategies.
87
+ Call `buildMigrationPlan()` to group recommendations into phases by risk (low, medium, high). High-risk items include adapter strategies.
122
88
 
123
89
  ### Step 6: Audit UX Completeness
124
90
 
125
- Evaluate frontend codebase across 8 UX categories: accessibility, error/empty/loading states, form validation, performance feel, copy consistency, design system alignment.
91
+ Call `auditUxCompleteness()` to evaluate 8 UX categories. The auditor determines status (present/partial/missing). Fill in `recommendedLibrary` on partial/missing items based on project context.
126
92
 
127
93
  ### Step 7: Apply Constraints and Serialize
128
94
 
@@ -130,73 +96,21 @@ Filter by license allowlist, detect dependency conflicts, serialize to JSON.
130
96
 
131
97
  ### Optional Steps
132
98
 
133
- - **Step 8**: Vulnerability scanning via OSV database
134
- - **Step 9**: Auto-update existing dependencies via registry queries
135
- - **Step 10**: PR auto-creation via GitHub/GitLab API
136
-
137
- ## Programmatic API
138
-
139
- ```typescript
140
- import { analyze, scanCodebase } from './src/index.js';
141
- import type { Recommender, GapRecommendation } from './src/index.js';
142
-
143
- // Step 1: Scan standalone (for AI agent inspection)
144
- const scanResult = await scanCodebase(validatedInput);
145
-
146
- // Step 2: Full pipeline with recommender + gap analysis
147
- const recommender: Recommender = (detection) => ({
148
- library: 'zustand',
149
- version: '^5.0.0',
150
- license: 'MIT',
151
- rationale: 'Minimal state library — no providers, 1KB gzipped',
152
- });
153
-
154
- const gaps: GapRecommendation[] = [
155
- {
156
- domain: 'observability',
157
- description: 'No structured logging detected',
158
- recommendedLibrary: {
159
- name: 'pino', version: '^9.0.0', license: 'MIT',
160
- rationale: 'Fastest Node.js JSON logger with redaction and child loggers',
161
- },
162
- priority: 'critical',
163
- },
164
- ];
165
-
166
- const result = await analyze({
167
- input: inputJson,
168
- context7Client: myContext7Client,
169
- recommender,
170
- gaps, // AI agent identifies missing capabilities
171
- });
172
- ```
99
+ - **Step 8**: Vulnerability scan via OSV database (`vulnClient`)
100
+ - **Step 9**: Auto-update existing dependencies (`registryClient`)
101
+ - **Step 10**: PR auto-creation via GitHub/GitLab (`platformClient` + `gitOps`)
173
102
 
174
- ## Output Artifacts
103
+ ## Output
175
104
 
176
105
  Single `OutputSchema` JSON containing:
177
106
  - `recommendedChanges` — replacement recommendations with scores, verification, adapter strategies
178
107
  - `gapAnalysis` (optional) — missing capabilities with prioritized recommendations
179
108
  - `filesToDelete` — file paths to remove after migration
180
109
  - `linesSavedEstimate` — total lines saved
181
- - `uxAudit` — UX completeness checklist
110
+ - `uxAudit` — UX completeness checklist (8 categories)
182
111
  - `migrationPlan` — phased plan with deletion checklist
183
112
  - `vulnerabilityReport` (optional)
184
113
  - `updatePlan` (optional)
185
114
  - `pullRequests` (optional)
186
115
 
187
- ## Vibe Coding Domain Coverage (20+ detection patterns)
188
-
189
- | Category | Domains |
190
- |----------|---------|
191
- | UX / Design | ux-completeness, a11y-accessibility, forms-ux, state-management |
192
- | SEO / i18n / Content | seo, i18n, content-marketing |
193
- | Growth / Data | growth-hacking |
194
- | App Architecture | agent-architecture, data-fetching-caching, error-handling-resilience |
195
- | Backend / Platform | database-orm-migrations, auth-security |
196
- | Observability | observability, logging-tracing-metrics |
197
- | Testing | testing-strategy |
198
- | AI Engineering | ai-model-serving |
199
- | Business | cross-border-ecommerce |
200
- | File / Media | file-upload-media |
201
-
202
- > **Extensibility:** Use `customDomains?: string[]` in input for project-specific domains.
116
+ Read `src/schemas/output.schema.ts` for the full schema.
@@ -25,10 +25,13 @@ export interface PatternDefinition {
25
25
  }
26
26
  /**
27
27
  * Returns the full pattern catalog covering Vibe Coding domains.
28
- * Each covered domain has 2–3 patterns for hand-rolled code detection.
28
+ *
29
+ * Domain assignment rules:
30
+ * - Each pattern goes in its MOST SPECIFIC domain (e.g., A/B test → ab-testing-experimentation, not growth-hacking)
31
+ * - Parent domains (growth-hacking, observability, ux-completeness) are used only when no specific child domain fits
32
+ * - Domains with no regex-detectable patterns are left for Gap Analysis (AI Agent)
29
33
  *
30
34
  * The catalog defines WHAT to detect, not WHAT to recommend.
31
- * Library recommendations are generated dynamically by the AI agent.
32
35
  */
33
36
  export declare function getPatternCatalog(): PatternDefinition[];
34
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAuiBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}
1
+ {"version":3,"file":"pattern-catalog.d.ts","sourceRoot":"","sources":["../../src/analyzer/pattern-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,EAAE,CAkqBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAExE"}