Chuyển đến nội dung
Skillpedia
Lập trình chung7.8k · #13039

codebase-pattern-analyzer

Skill này làm gì

Skill này hướng dẫn AI agent đọc một mã nguồn tham chiếu và mô tả kiến trúc có thể tái sử dụng của nó. Nó dành cho nhà phát triển muốn hiểu hoặc sao chép cấu trúc và quy ước của một dự án.

Khi nào nên dùng

  • ✓Khi bạn cần hiểu một mã nguồn lớn được tổ chức thế nào trước khi sao chép nó.
  • ✓Khi bạn muốn lấy một mẫu cụ thể, như lớp dịch vụ hoặc API proxy, từ một dự án tham chiếu.
  • ✓Khi bạn bắt đầu một dự án mới nên theo quy ước của một dự án hiện có.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/codebase-pattern-analyzer/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/codebase-pattern-analyzer/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Nghiên cứu dự án tham chiếu này và mô tả các mẫu component, dịch vụ và API của nó để tôi xây một ứng dụng tương tự.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent lập bản đồ cấu trúc thư mục và phân loại từng thư mục theo vai trò, như component, service, config, style, utils và tầng API. Sau đó nó đọc các file của từng vai trò để mô tả mẫu bằng các thuật ngữ rõ ràng, có thể tái sử dụng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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:

  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-tr
Câu hỏi thường gặp

Agent phân loại thư mục như thế nào?

Nó gán mỗi thư mục một vai trò, như component, service hoặc tầng API, dựa trên tên và nội dung thông thường.

Đầu ra là gì?

Skill tạo ra các mô tả mẫu có cấu trúc, sau này có thể được chuyển thành skill độc lập.

Nó có thay đổi dự án tham chiếu không?

Skill là một phương pháp phân tích, nên nó đọc mã nguồn để mô tả chứ không sửa đổi.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#13039
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự