extract-shared
Skill3 starsChanged 5 months agoMITView on GitHub
Identify cross-project code duplication and generate candidates for a shared utility package.
- Reads credentials
In this repository67 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- optimize-contextSkill
- a11y-checkSkill
- api-contractSkill
- backend-patternsSkill
- build-fixSkill
- checkpointSkill
- clickhouse-ioSkill
- code-review-eccSkill
- code-reviewSkill
- coding-standardsSkill
- config-auditSkill
- continuous-learning-v2Skill
- create-prdSkill
- deps-auditSkill
- e2eSkill
- eval-harnessSkill
- evalSkill
- evolveSkill
- executeSkill
- execution-reportSkill
- firecrawlSkill
- frontend-designSkill
- frontend-patternsSkill
- golang-patternsSkill
- golang-testingSkill
- implement-fixSkill
- init-projectSkill
- instinct-exportSkill
- instinct-importSkill
- instinct-statusSkill
- iterative-retrievalSkill
- lazySkill
- learnSkill
- orchestrateSkill
- perf-profileSkill
- plan-eccSkill
- plan-featureSkill
- postgres-patternsSkill
- primeSkill
- project-guidelines-exampleSkill
- projectSkill
- prompt-auditSkill
- python-patternsSkill
- python-reviewSkill
- python-testingSkill
- rcaSkill
- refactor-cleanSkill
- releaseSkill
- security-reviewSkill
- seo-kitSkill
- set-working-dirSkill
- skill-createSkill
- strategic-compactSkill
- supadataSkill
- system-reviewSkill
- tddSkill
- tdd-workflowSkill
- test-coverageSkill
- testSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
No arguments or
--scan: Run full scan and report (default) - Very specific: line 25
--python: Only scan Python projects - Very specific: line 26
--node: Only scan Node.js projects - Distinctive: line 35
Search for health endpoint implementations:
- Distinctive: line 47
Search for custom exception classes and error response patterns:
- Distinctive: line 58
Search for config loading patterns:
- Distinctive: line 118
Read the relevant function/class from each project
- Distinctive: line 210
If a project path doesn't exist, skip it
- Distinctive: line 211
If grep finds no matches in a category, report "No instances found"
- Distinctive: line 213
Never modify any project files — this is analysis only
- Distinctive: line 218
Use the report to plan extraction work in a follow-up session
- Distinctive: line 222
Run this quarterly or before starting a new project
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Shared Utilities Extractor
Scan your projects for duplicated patterns and identify candidates for extraction into a shared utility package.
Selecting Projects to Scan
Decide what to scan, in this order:
- Paths passed as arguments — scan exactly those project directories.
- A workspace root — if you keep several projects under one directory (e.g.
~/projects), scan each immediate subdirectory. - The current directory — if neither applies, this skill needs at least two projects to compare; ask the user to point it at a workspace root or a set of paths.
Arguments
Parse $ARGUMENTS:
- No arguments or
--scan: Run full scan and report (default) --report: Show results from last scan without re-scanning--python: Only scan Python projects--node: Only scan Node.js projects
Process
Step 1: Define Search Patterns
Scan for these known duplication categories across the selected projects:
Category 1: Health Check Endpoints
Search for health endpoint implementations:
# Python
grep -rn "def health" --include="*.py" <path>
grep -rn "/health" --include="*.py" <path>
# Node/TypeScript
grep -rn "'/health'" --include="*.ts" --include="*.js" <path>
grep -rn "\"/health\"" --include="*.ts" --include="*.js" <path>Category 2: Error Response Formats
Search for custom exception classes and error response patterns:
# Python
grep -rn "class.*Error.*Exception" --include="*.py" <path>
grep -rn "class.*APIError\|class.*AppError\|class.*ServiceError" --include="*.py" <path>
# Node/TypeScript
grep -rn "class.*Error extends" --include="*.ts" --include="*.js" <path>Category 3: Configuration / Settings Patterns
Search for config loading patterns:
# Python
grep -rn "os.environ\|os.getenv\|environ.get" --include="*.py" <path> | head -10
grep -rn "class.*Config\|class.*Settings" --include="*.py" <path>
# Node/TypeScript
grep -rn "process.env" --include="*.ts" --include="*.js" <path> | head -10Category 4: Authentication / Rate Limiting
# Python
grep -rn "rate.limit\|RateLimiter\|throttle" --include="*.py" <path>
grep -rn "auth.*decorator\|login_required\|verify_token" --include="*.py" <path>
# Node/TypeScript
grep -rn "rateLimit\|rate-limit" --include="*.ts" --include="*.js" <path>
grep -rn "authenticate\|verifyToken\|authMiddleware" --include="*.ts" --include="*.js" <path>Category 5: Database Utilities
# Python
grep -rn "def get_db\|def create_tables\|def run_migration" --include="*.py" <path>
grep -rn "session.execute\|session.commit" --include="*.py" <path> | head -5
# Node/TypeScript
grep -rn "getConnection\|createPool\|query(" --include="*.ts" --include="*.js" <path>Category 6: Encryption / Secrets Helpers
grep -rn "Fernet\|encrypt\|decrypt\|hashlib\|bcrypt" --include="*.py" <path>
grep -rn "crypto\|encrypt\|decrypt\|hash" --include="*.ts" --include="*.js" <path>Category 7: Audit Logging
grep -rn "record_audit\|audit_log\|log_action\|telemetry" --include="*.py" <path>Category 8: Docker Health Checks
grep -rn "healthcheck\|HEALTHCHECK" <path>/docker-compose*.yml <path>/Dockerfile 2>/dev/nullStep 2: Collect and Compare
For each category, collect the implementations found across projects. Use the Grep tool for each pattern across each project directory.
Group results by category and compare:
- How many projects implement this pattern?
- Are the implementations similar enough to share?
- What's the effort to extract vs. keep separate?
Step 3: Analyze Similarity
For patterns found in 2+ projects, read the actual implementation files and compare:
- Read the relevant function/class from each project
- Assess similarity (identical, similar with minor differences, fundamentally different)
- Rate extraction feasibility: Easy (copy-paste), Medium (needs abstraction), Hard (too different)
Step 4: Report
## Cross-Project Duplication Report
### High-Value Extraction Candidates (found in 3+ projects)
#### 1. Health Check Endpoints
- **Projects:** api-service, web-app, dashboard, platform
- **Pattern:** GET /health returning {status: "healthy", service: "<name>"}
- **Similarity:** High — nearly identical implementations
- **Extraction effort:** Easy
- **Recommendation:** Create shared `health_check()` factory function
#### 2. Error Response Formats
- **Projects:** api-service, web-app
- **Pattern:** Custom exception classes with JSON error responses
- **Similarity:** Medium — same structure, different exception types
- **Extraction effort:** Medium
- **Recommendation:** Create shared base error classes with JSON serialization
### Medium-Value Candidates (found in 2 projects)
#### 3. Encryption Utilities
- **Projects:** api-service (Fernet), web-app (potential)
- **Similarity:** Low — only one project has it currently
- **Extraction effort:** Easy
- **Recommendation:** Extract if second project needs it
...
### Not Worth Extracting (domain-specific)
- Business-logic parsers unique to a single project
- Third-party integration sync code used by only one project
- Bespoke handlers unique to one product
### Proposed Shared Package Structure
If extracting a Python shared package (`shared-common`):shared-common/ ├── pyproject.toml ├── shared_common/ │ ├── init.py │ ├── health.py # Health check endpoint factory │ ├── errors.py # Base error classes │ ├── config.py # Configuration loader │ ├── auth.py # Auth decorators │ ├── audit.py # Audit logging │ └── encryption.py # Encryption helpers └── tests/ └── ...
If extracting a Node shared package (`@yourorg/common`):shared-common-node/ ├── package.json ├── src/ │ ├── health.ts │ ├── errors.ts │ ├── config.ts │ └── auth.ts └── tests/ └── ...
### Summary
| Category | Projects | Similarity | Effort | Priority |
|----------|----------|-----------|--------|----------|
| Health checks | 4 | High | Easy | HIGH |
| Error formats | 2 | Medium | Medium | MEDIUM |
| Config loading | 4 | Medium | Medium | MEDIUM |
| Rate limiting | 2 | Low | Medium | LOW |
| Encryption | 1+ | N/A | Easy | LOW |
| Audit logging | 2 | Medium | Medium | MEDIUM |
| Docker health | 3 | High | Easy | HIGH |
Total duplication categories: X
Worth extracting now: Y
Worth extracting later: Z
Domain-specific (keep separate): WError Handling
- If a project path doesn't exist, skip it
- If grep finds no matches in a category, report "No instances found"
- Large result sets: limit to first 10 matches per project per category
- Never modify any project files — this is analysis only
Notes
- This skill is read-only — it identifies duplication but does not extract or create packages
- Use the report to plan extraction work in a follow-up session
- Focus on patterns that appear in 3+ projects for highest ROI
- Domain-specific code (single-project business logic, one-off integrations) should stay in its project
- The proposed package structure is a recommendation — adjust based on actual findings
- Run this quarterly or before starting a new project
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

