Pattern Extraction
FreeNo executable scriptsNot checkedDetect and extract patterns from codebases for template generation
by TheLobbi★ 22 GitHub starsAbout this skill
Pattern Extraction Skill
When to Use This Skill
Use pattern extraction when you need to:
- Analyze existing infrastructure to create reusable templates
- Convert hardcoded values into configurable template variables
- Identify configuration patterns across multiple similar files
- Detect technology stacks and their conventions
- Extract naming conventions and structural patterns
- Generate template metadata from existing code
- Create variable schemas from inferred types and constraints
Perfect for:
- Converting existing IaC to templates
- Building template libraries from production code
- Standardizing infrastructure patterns
- Automating template generation
- Identifying refactoring opportunities
Core Capabilities
1. Technology Stack Detection
Automatically identify:
- IaC Frameworks: Terraform, Pulumi, CloudFormation, ARM, Bicep
- Cloud Providers: AWS, Azure, GCP, multi-cloud patterns
- Service Types: Kubernetes, Docker, serverless, containers
- Configuration Formats: YAML, JSON, HCL, TOML
- Build Systems: Helm, Kustomize, Jsonnet
- CI/CD Platforms: GitHub Actions, GitLab CI, Jenkins, Harness
2. Configuration Pattern Extraction
Extract patterns from:
- Resource definitions and relationships
- Environment-specific configurations
- Naming conventions and tagging strategies
- Security policies and compliance rules
- Network topologies and architectures
- Deployment strategies and workflows
3. Variable Identification
Intelligent detection of:
- Hardcoded Values: Strings, numbers, booleans that should be variables
- Repeated Values: Values appearing multiple times across files
- Environment Indicators: dev, staging, prod patterns
- Naming Patterns: Prefixes, suffixes, delimiters
- Secret Patterns: API keys, passwords, tokens (flag for security)
- Configuration Schemas: Type inference from usage
4. Structure Analysis
Analyze:
- File organization and directory structure
- Module boundaries and dependencies
- Resource hierarchies and relationships
- Configuration inheritance patterns
- Composition and reuse strategies
- Template inclusion patterns
Pattern Detection Matrix
| Pattern Type | Indicators | Extraction Method | Output Format |
|---|---|---|---|
| Environment Values | dev, staging, prod in names |
Context-aware regex | {{ environment }} |
| Resource Names | Repeated prefixes/suffixes | Token analysis | {{ project_name }}-{{ resource_type }} |
| Region/Location | us-east-1, westeurope |
Cloud provider patterns | {{ region }} |
| Version Numbers | Semantic versioning patterns | Regex + validation | {{ version }} |
| Port Numbers | Common service ports | Port range analysis | {{ port }} |
| Size/Scale | Instance types, node counts | Capacity patterns | {{ instance_size }} |
| CIDR Blocks | IP address ranges | Network pattern analysis | {{ cidr_block }} |
| Tags/Labels | Key-value metadata | Metadata extraction | {{ tags }} |
| Secret References | Vault paths, secret names | Secret pattern detection | {{ secret_ref }} (secure) |
| Feature Flags | Boolean toggles | Conditional analysis | {{ enable_feature }} |
Variable Inference Rules
Before/After Transformation Examples
Example 1: Resource Names
Before:
resource "aws_instance" "web_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t3.medium"
tags = {
Name = "myapp-web-server-prod"
Environment = "production"
Project = "myapp"
}
}
After:
resource "aws_instance" "web_server" {
ami = "{{ ami_id }}"
instance_type = "{{ instance_type }}"
tags = {
Name = "{{ project_name }}-web-server-{{ environment }}"
Environment = "{{ environment }}"
Project = "{{ project_name }}"
}
}
Extracted Variables:
variables:
ami_id:
type: string
description: "AMI ID for the EC2 instance"
default: "ami-0c55b159cbfafe1f0"
pattern: "^ami-[a-f0-9]{17}$"
instance_type:
type: string
description: "EC2 instance type"
default: "t3.medium"
allowed_values: ["t3.micro", "t3.small", "t3.medium", "t3.large"]
project_name:
type: string
description: "Project identifier used in resource naming"
default: "myapp"
pattern: "^[a-z][a-z0-9-]{2,30}$"
environment:
type: string
description: "Deployment environment"
default: "production"
allowed_values: ["dev", "staging", "production"]
Example 2: Kubernetes Deployment
Before:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: production
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
version: "1.21.0"
spec:
containers:
- name: nginx
image: nginx:1
Install Pattern Extraction in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the Pattern Extraction skill do?
Detect and extract patterns from codebases for template generation
How do I install the Pattern Extraction skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the Pattern Extraction skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic