SuperAPI AI Directory

gravito-architect

Coding & development

View repository

Updated 10-16 05:50

About this skill

Gravito Architect

Overview

Gravito Architect helps developers transform "AI-assisted generated code" into a "technical architecture fully mastered by developers," with a focus on:

  • Explaining logic and data flow
  • Defining clear API interfaces
  • Revealing potential risks (N+1, Race Condition, memory leaks)
  • Explaining key design decisions

Workflow

Step 1: Understand the input content

Ask the user to provide the following information:

  1. Core code: The main file path to be analyzed
  2. Interface definitions: Related types.ts or interfaces.ts(if present)
  3. Test cases: Related test files (optional, but helpful for understanding expected behavior)
  4. Analysis scope:
    • Full analysis (including all sections)
    • Focused analysis (only specific sections, such as: performance, design decisions)

Example question:

為了生成準確的技術規格,請提供:
1. 核心程式碼檔案路徑(如:`packages/atlas/src/QueryBuilder.ts`)
2. 相關的型別定義檔案(如:`packages/atlas/src/types.ts`)
3. 測試檔案路徑(如:`packages/atlas/tests/QueryBuilder.test.ts`)

請問需要完整分析,還是僅關注特定面向(如:效能優化、設計決策)?

Step 2: Read and analyze the code

Use the Read tool to read all related files:

// 依序讀取:
// 1. 核心程式碼
// 2. 型別定義
// 3. 測試案例

Analysis focus:

  • Identify the main classes/functions and their responsibilities
  • Trace data flow (input → processing → output)
  • Check design patterns (such as: Builder, Factory, Proxy)
  • Check for potential issues (refer to references/analysis-checklist.md)

Step 3: Perform in-depth analysis

Follow references/analysis-checklist.md to perform the mandatory check items:

  1. N+1 query problem: Check for database queries inside loops
  2. Race Condition: Check shared state in asynchronous operations
  3. Memory leaks: Check event listeners, timers, caches
  4. Type safety: Check any usage, generic constraints
  5. Exception handling: Check try-catch coverage
  6. Performance bottlenecks: Check time complexity, nested loops
  7. Security issues: Check input validation, SQL Injection

Important: Each issue must provide:

  • Specific location (file name:line number)
  • Impact assessment
  • Actionable fix suggestions

Step 4: Generate the technical specification document

Generate the document according to the structure of references/output-template.md , including:

  1. Module overview
  2. Technical specifications(API Signature + data flow)
  3. Key design decisions
  4. Performance and scalability
  5. Edge cases and limitations
  6. Follow-up optimization suggestions

Output method:

  • Dialog box: A brief Executive Summary highlighting key findings
  • Markdown block: The complete technical specification content, which can be directly copied into the project's /docs Table of Contents

Step 5: Provide Copyable Documentation

Use assets/DOCS_ARCH_template.md as a basis to generate ready-to-use Markdown files:

建議將此文檔儲存為:`docs/architecture/[模組名稱].md`

您可以直接複製以下內容:

\`\`\`markdown
[完整的技術規格內容]
\`\`\`

Output Quality Standards

Principles That Must Be Followed

  1. Language: Use Traditional Chinese (Taiwan) terminology throughout
  2. Code Comments: Comments in sample code should also be in Chinese
  3. Quantitative Data: Performance improvements must include specific data (e.g., "from O(n²) to O(n)")
  4. Specific Recommendations: Avoid vague recommendations (e.g., "strengthen testing"); specify which scenarios to test
  5. Problem Location: Mark the file location for every issue (檔案名稱:行號)

Checklist

Before outputting, confirm:

  • Did it proactively identify N+1, Race Condition, and memory leaks?
  • Does every design decision explain the "alternative" and its disadvantages?
  • Does the performance optimization provide quantitative data?
  • Do edge cases include "workarounds"?
  • Are follow-up recommendations divided into short-term, mid-term, and long-term?

References

Detailed Template

  • Output Structure: Refer to references/output-template.md to view the complete example
  • Analysis Method: Refer to references/analysis-checklist.md to learn how to identify problems

Copyable Template

  • Document Template:assets/DOCS_ARCH_template.md provides a blank template

Special Considerations

Specific Requirements for the Gravito Project

Since this skill is designed specifically for the Gravito framework, please pay special attention to:

  1. Atlas ORM:

    • Check the performance of the query builder (Eager Loading, N+1 issues)
    • Analyze the JOIN strategy for related queries
    • Check the transaction isolation level
  2. Luminosity:

    • Check parameter validation for HTTP routes
    • Analyze the execution order of middleware
    • Check the error handling mechanism
  3. Bun Runtime:

    • Leverage Bun's native APIs (e.g.,Bun.file(), Bun.write())
    • Check whether Node.js-specific APIs are used by mistake

Example Interaction

User Request

我剛完成 Atlas 的 QueryBuilder 模組,請幫我產出技術規格書。

檔案位置:
- packages/atlas/src/QueryBuilder.ts
- packages/atlas/src/types/QueryTypes.ts
- packages/atlas/tests/QueryBuilder.test.ts

Gravito Architect Response

Step 1: Read the file

正在讀取以下檔案:
- packages/atlas/src/QueryBuilder.ts
- packages/atlas/src/types/QueryTypes.ts
- packages/atlas/tests/QueryBuilder.test.ts

Step 2: Perform analysis

分析完成!主要發現:
✅ 無 N+1 查詢問題(已使用 Eager Loading)
⚠️  發現潛在 Race Condition(並發更新時無鎖保護)
✅ 記憶體管理良好(無洩漏風險)

Step 3: Output an executive summary

## 執行摘要

**核心功能**:QueryBuilder 提供類型安全的鏈式查詢 API

**關鍵優點**:
- 使用 Proxy 實現延遲執行,避免過早查詢
- 內建查詢快取,重複查詢效能提升 98%

**需注意問題**:
- 並發更新場景存在 Race Condition(建議使用樂觀鎖)
- 不支援子查詢(需手動使用 `whereRaw()`)

**建議優先處理**:
1. 新增樂觀鎖支援(Critical)
2. 實作子查詢語法(High)

Step 4: Provide complete documentation

完整的技術規格文檔如下(可複製到 `docs/architecture/QueryBuilder.md`):

\`\`\`markdown
[完整的 6 個章節內容]
\`\`\`

Error Handling

Common Issues

  1. Incorrect File Path:

    • Prompt the user to check the path
    • Use the Glob tool to search for possible file locations
  2. Code Is Too Complex:

    • Ask the user whether it should be split into multiple documents
    • Suggest analyzing the core functionality first, then expanding to auxiliary modules
  3. Missing Type Definitions:

    • Infer types from the code itself
    • Mark it as "recommend adding type definitions"

Continuous Improvement

If the user is not satisfied with the output, ask:

  • Which sections need more detail?
  • Should analysis of specific aspects be added?
  • Does the document style meet expectations?

Adjust the output based on feedback until the user is satisfied.