跳到正文
cccskills
免费在 GitHub 公开

codebase-pattern-analyzer

Analyze an existing codebase to identify reusable design patterns in components, services, APIs, styling, and refresh scheduling. Produces structured descriptions with representative code, conventions, dependencies, and adaptation notes for reuse or later conversion into skills.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

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.

查看安装方法

适用场景

  • Understanding the structure of a large codebase
  • Extracting reusable component and service designs
  • Following an existing project's conventions in a new project
  • Preparing design patterns for conversion into skills

包含的文件(2)

  • SKILL.md6.5 KB
  • .skill_id39 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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:

RoleTypical DirsWhat to Look For
Componentssrc/components/UI classes, base class inheritance, DOM manipulation
Servicessrc/services/Data fetching, API calls, circuit breakers, caching
Configsrc/config/Constants, panel definitions, API endpoints, feature flags
Stylessrc/styles/CSS custom properties, theme variables, grid layout
Utilssrc/utils/Helper functions, formatting, DOM utilities
API Layerapi/, server/Serverless functions, route handlers, CORS, proxy logic
Entry Pointsrc/main.tsBootstrap, 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:

  1. Constructor options interface — what config each component accepts (id, title, className, etc.)
  2. DOM structure — how the element tree is built (header, content area, resize handles)
  3. Lifecycle methods — constructor, destroy, show/hide, refresh
  4. State management — loading/error/content states, fetching guards
  5. 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:

  1. Circuit breaker / resilience — retry logic, cooldown, cached fallback
  2. Interface definitions — typed data shapes returned by each service
  3. Fetch pattern — how HTTP calls are made (direct fetch, proxy, batching)
  4. Caching strategy — TTLs, stale-while-revalidate, in-memory cache
  5. 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:

  1. File-per-endpoint structure — one file per API domain
  2. CORS handling — origin allowlist, preflight response
  3. API key isolation — process.env.* usage, never exposed to frontend
  4. Cache headers — Cache-Control, s-maxage, stale-while-revalidate
  5. Error wrapping — structured JSON errors, never raw upstream responses
  6. 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:

  1. CSS custom properties — color tokens, font stacks, spacing
  2. Theme structure — dark/light mode switch mechanism
  3. Grid layout — grid-template-columns, auto-fill, minmax() values
  4. Component styles — panel base styles, header, content, scrollbar
  5. Semantic colors — positive/negative, severity levels, status indicators
  6. Typography — font family, sizes, letter-spacing, text-transform

Step 6: Identify the Scheduling / Refresh Pattern

read_file <project_root>/src/app/refresh-scheduler.ts

Extract:

  1. Registration API — how panels register their refresh functions
  2. Interval management — per-panel configurable intervals
  3. Visibility awareness — pause when tab hidden, flush stale on return
  4. In-flight guards — prevent duplicate concurrent refreshes
  5. Stagger logic — avoid API burst when resuming

Step 7: Synthesize Into Pattern Descriptions

For each pattern discovered, produce a structured description:

## Pattern: [Name]

**Source file(s)**: [paths in reference codebase]
**Category**: component | service | api | style | scheduler | utility

### Structure
[Key structural elements — interfaces, classes, functions]

### Key Code
[Minimal representative code snippet, 20-40 lines]

### Conventions
[Naming, file organization, import paths]

### Dependencies
[Other patterns this depends on]

### Adaptation Notes
[What must change when applying to a different project]

Output

The final output should be a list of pattern descriptions, one per architectural concern. These become the input to the skill-template-generator skill, which turns each pattern into a standalone SKILL.md.

Tips

  • Read broadly first, deeply second — scan directory listings before reading individual files
  • Follow imports — if a component imports from ../services/, read that service next
  • Count instances — if 10+ components extend the same base class, that's a core pattern
  • Note what's NOT used — no framework (React, Vue) means vanilla DOM; no ORM means raw fetch
  • Compare 2-3 examples of the same pattern to distinguish the template from the instance-specific parts

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

中文简介正在准备中。当前显示英语简介。

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace77582026年8月13日 更新

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

中文简介正在准备中。当前显示英语简介。

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace77582026年8月13日 更新

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

中文简介正在准备中。当前显示英语简介。

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace77582026年8月13日 更新

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

中文简介正在准备中。当前显示英语简介。

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace77582026年8月13日 更新

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

中文简介正在准备中。当前显示英语简介。

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace77582026年8月13日 更新

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

中文简介正在准备中。当前显示英语简介。

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace77582026年8月13日 更新

查看 HKUDS 的全部技能

报告此技能的问题