Universal pattern detector - learns from ANY codebase through sample analysis
View on GitHubSelect agents to install to:
npx add-skill https://github.com/jhlee0409/claude-plugins/blob/main/plugins/oas/skills/pattern-detector/SKILL.md -a claude-code --skill pattern-detectorInstallation paths:
.claude/skills/pattern-detector/# Pattern Detector
Analyze ANY codebase to learn existing API patterns. Works with any framework, structure, or convention.
---
## EXECUTION INSTRUCTIONS
When this skill is invoked, Claude MUST perform these steps in order:
### Step 1: Read package.json
1. Use `Read` tool to read `package.json` in project root
2. Extract dependency information:
- `dependencies`
- `devDependencies`
3. If package.json not found โ Report error and abort
### Step 2: Detect Framework Stack
From package.json, identify:
| Category | Check for | Result |
|----------|-----------|--------|
| Framework | `react`, `vue`, `@angular/core`, `svelte` | Set `framework` |
| HTTP Client | `axios`, `ky`, `got` | Set `httpClient` |
| Data Fetching | `@tanstack/react-query`, `swr`, `@reduxjs/toolkit` | Set `dataFetching` |
| Language | `typescript` in devDeps | Set `language` to `typescript` or `javascript` |
Report findings:
```
๐ฆ package.json analysis:
Framework: <framework> + <language>
HTTP Client: <httpClient or "fetch (native)">
Data Fetching: <dataFetching or "none detected">
```
### Step 3: Search for Existing API Code
Use `Glob` tool with these patterns in order:
```
1. src/**/api/**/*.{ts,js,tsx,jsx}
2. src/**/services/**/*.{ts,js}
3. src/**/hooks/**/*{api,query,fetch}*.{ts,js}
4. lib/api/**/*.{ts,js}
5. api/**/*.{ts,js}
```
If NO files found:
- Report: `๐ No existing API code found`
- Skip to Step 6 (Interactive Fallback)
If files found:
- Report: `๐ Found <count> potential API files`
- Continue to Step 4
### Step 4: Analyze Sample Files
For each discovered file (max 5 files):
1. Use `Read` tool to read file content
2. Extract patterns:
- **Import patterns**: What modules are imported, how (named, default, namespace)
- **Export patterns**: Named exports, default exports, barrel exports
- **Function patterns**: Arrow vs declaration, async, parameter style
- **HTTP call patterns**: How HTTP requests are made
- **Type patterns**: Interface vs type,