codebase-pattern-analyzer
What it does
This skill guides the AI agent to read a reference codebase and describe its reusable architecture. It is for developers who want to understand or copy a project's structure and conventions.
When to use it
- βWhen you need to understand how a large codebase is organized before copying it.
- βWhen you want one specific pattern, such as a service layer or API proxy, pulled out of a reference project.
- βWhen you are starting a new project that should follow the conventions of an existing one.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/codebase-pattern-analyzer/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βStudy this reference project and describe its component, service and API patterns so I can build a similar app.β
5 new skills a week. 1 minute to read.
How it works
The agent maps the directory structure and sorts each folder into roles such as components, services, config, styles, utils and the API layer. It then reads each role's files to describe the patterns in plain, reusable terms.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Codebase Pattern Analyzer
Systematically analyze a reference codebase and extract reusable architectural patterns into structured descriptions. These descriptions become the raw material for new skills (via the skill-template-generator skill).
When to Use
- You need to understand how a large codebase is structured before replicating it
- You want to extract a specific pattern (component architecture, service layer, API proxy, etc.) from a reference project
- You are bootstrapping a new project that should follow the conventions of an existing one
Step 1: Map the Directory Structure
Read the top-level directory and identify the major code zones:
list_dir <project_root>
list_dir <project_root>/src
Classify each directory into one of these roles:
| Role | Typical Dirs | What to Look For |
|---|---|---|
| Components | src/components/ |
UI classes, base class inheritance, DOM manipulation |
| Services | src/services/ |
Data fetching, API calls, circuit breakers, caching |
| Config | src/config/ |
Constants, panel definitions, API endpoints, feature flags |
| Styles | src/styles/ |
CSS custom properties, theme variables, grid layout |
| Utils | src/utils/ |
Helper functions, formatting, DOM utilities |
| API Layer | api/, server/ |
Serverless functions, route handlers, CORS, proxy logic |
| Entry Point | src/main.ts |
Bootstrap, panel instantiation, scheduler setup |
Step 2: Identify the Component Pattern
Find the base component class (usually the most imported file in components/):
read_file <project_root>/src/components/Panel.ts
Extract these structural elements:
- Constructor options interface β what config each component accepts (id, title, className, etc.)
- DOM structure β how the element tree is built (header, content area, resize handles)
- Lifecycle methods β constructor, destroy, show/hide, refresh
- State management β loading/error/content states, fetching guards
- Data binding β how data flows from service β render β DOM
Record the pattern as:
COMPONENT PATTERN:
Base class: [name]
Options: [list of constructor params]
DOM tree: [element hierarchy]
States: [loading, error, content]
Lifecycle: [init β fetch β render β destroy]
Key methods: [getElement, showLoading, showError, setContent, refresh, destroy]
Step 3: Identify the Service Layer Pattern
Examine 2-3 service files to find the common structure:
read_file <project_root>/src/services/news.ts
read_file <project_root>/src/services/stock-market.ts
Look for:
- Circuit breaker / resilience β retry logic, cooldown, cached fallback
- Interface definitions β typed data shapes returned by each service
- Fetch pattern β how HTTP calls are made (direct fetch, proxy, batching)
- Caching strategy β TTLs, stale-while-revalidate, in-memory cache
- Error handling β what happens on failure, default return values
Record as:
SERVICE PATTERN:
Resilience: [circuit breaker with N failures β cooldown]
Cache: [in-memory, TTL=Xms]
Fetch: [browser fetch β /api/... proxy β external API]
Error: [catch β recordFailure β return default]
Exports: [async functions, not class instances]
Step 4: Identify the API Proxy Pattern
Read the server-side proxy layer:
list_dir <project_root>/api/
read_file <project_root>/api/_cors.js
read_file <project_root>/api/stocks.ts # or similar endpoint
Extract:
- File-per-endpoint structure β one file per API domain
- CORS handling β origin allowlist, preflight response
- API key isolation β
process.env.*usage, never exposed to frontend - Cache headers β
Cache-Control,s-maxage,stale-while-revalidate - Error wrapping β structured JSON errors, never raw upstream responses
- Input validation β query parameter checks before upstream call
Step 5: Identify the Styling System
read_file <project_root>/src/styles/main.css # first 100 lines for CSS variables
Extract:
- CSS custom properties β color tokens, font stacks, spacing
- Theme structure β dark/light mode switch mechanism
- Grid layout β
grid-template-columns,auto-fill,minmax()values - Component styles β panel base styles, header, content, scrollbar
- Semantic colors β positive/negative, severity levels, status indicators
- Typography β font family, sizes, letter-spacing, text-tr
FAQ
How does the agent sort the folders?
It assigns each folder a role, such as components, services or API layer, based on typical names and contents.
What is the output?
The skill produces structured pattern descriptions that can later be turned into standalone skills.
Does it change the reference project?
The skill is an analysis method, so it reads the codebase to describe it rather than edit it.
Details
Original description by the author
Analyze a reference codebase to discover and extract reusable architectural patterns. Produces structured pattern descriptions that can be turned into standalone skills. This is a meta-skill that bootstraps the skill evolution chain.
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #13039
- License
- MIT
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.