Communitygithub.com

reyalka/astro

在 Astro 單一儲存庫中進行開發的全面指南。涵蓋架構、除錯、測試及關鍵限制。在處理新功能、錯誤修復、測試或理解程式碼庫結構時使用。

astro 是什麼?

此技能專為在 Astro 單一儲存庫(monorepo)中工作的 AI 代理和開發者設計,提供基於任務的上下文載入機制。它能根據使用者的任務類型(例如新增核心功能、修復錯誤、撰寫測試或理解架構)推薦對應的文檔,如架構、除錯、測試和限制文件。技能還強調了關鍵的開發陷阱,例如優先使用單元測試而非整合測試、避免在 `runtime/` 模組中使用 Node.js API,以及必須為每個整合測試設定唯一的 `outDir` 以防止快取污染。此外,它提供了快速命令參考、關鍵檔案路徑、三種執行上下文(Node.js、Vite SSR、瀏覽器)及五種管線類型(如 RunnablePipeline、BuildPipeline)的摘要,幫助開發者快速上手。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/reyalka/astro/tree/HEAD/.agents/skills/astro-developer

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Astro 開發者技能

為在 Astro 單一儲存庫(monorepo)中工作的 AI 代理和開發者提供的上下文載入技能。根據您的任務載入相關文檔。

快速決策矩陣

您正在做什麼? → 閱讀這些文件:

任務主要文檔輔助文檔
新增核心功能architecture.md, constraints.mdtesting.md
修復錯誤debugging.mdarchitecture.md
撰寫/修正測試testing.mdconstraints.md
建立整合套件瀏覽 packages/integrations/ 中的範例testing.md
理解架構architecture.md-
處理錯誤debugging.md, constraints.mdtesting.md
理解限制constraints.mdarchitecture.md

重要警告

開始之前,請注意這些常見陷阱:

  1. 優先使用單元測試:預設編寫可單元測試的程式碼。只在必要時使用整合測試 → testing.md
  2. Node.js API 限制:無法在 runtime/ 程式碼中使用 Node.js API → constraints.md
  3. 測試隔離:每個整合測試必須設定唯一的 outDir → testing.md
  4. 執行環境邊界:核心 vs Vite vs 瀏覽器執行上下文 → architecture.md
  5. 預發布模式:Changesets 目標是 origin/next 分支(請檢查 .changeset/config.json)

快速命令參考

# 開發
pnpm install                                    # 安裝(僅限根目錄)
pnpm run build                                  # 建置所有套件
pnpm run dev                                    # 監看模式
pnpm run lint                                   # 程式碼檢查

# 測試
pnpm -C packages/astro exec astro-scripts test "test/**/*.test.js"  # 所有測試
pnpm -C packages/astro exec astro-scripts test -m "pattern"         # 篩選測試
pnpm run test:e2e                               # 端到端測試
node --test test/file.test.js                   # 單一測試

# 範例
pnpm --filter @example/minimal run dev          # 執行範例

# Changesets
pnpm exec changeset --empty                     # 建立 changeset,非互動模式

關鍵檔案路徑

packages/astro/src/
├── core/              # Node.js 執行上下文(建置/開發指令)
├── runtime/
│   ├── server/        # Vite SSR 執行上下文
│   └── client/        # 瀏覽器執行上下文
├── virtual-modules/   # 虛擬模組入口點
├── content/           # 內容層系統
├── vite-plugin-*/     # Vite 外掛
└── types/             # 集中式 TypeScript 型別

packages/integrations/  # 官方整合套件
examples/              # 在此測試您的變更
test/fixtures/         # 測試裝置

注意:node_modules/ 中的錯誤堆疊追蹤會對應到 packages/ 中的原始碼。詳情請見 architecture.md。

使用方式

此技能用於載入相關上下文,而非編排工作流程。載入適當文檔後:

  1. 閱讀針對您任務推薦的文件
  2. 套用其中描述的模式和限制
  3. 使用提供的命令和檔案路徑
  4. 如果遇到問題,搜尋文檔中的錯誤訊息

架構快速摘要

三個執行上下文:

  • core/ → Node.js,建置/開發指令,除 Vite 外掛外避免使用 Node APIs
  • runtime/server/ → Vite SSR,無法使用 Node APIs
  • runtime/client/ → 瀏覽器,完全無法使用 Node APIs

五種管線類型:

  • RunnablePipeline → 搭配 Vite 載入器系統的 astro dev
  • NonRunnablePipeline → 無運行時模組載入的 astro dev(Cloudflare 適配器)
  • BuildPipeline → astro build + 預渲染
  • AppPipeline → 正式環境無伺服器/SSR
  • ContainerPipeline → 容器 API

完整詳情請見 architecture.md。

測試快速摘要

理念:優先使用單元測試而非整合測試。預設編寫可單元測試的程式碼。

單元測試(快速,優先使用):

  • 測試純函數和業務邏輯
  • 從基礎設施中提取業務邏輯
  • 使用依賴注入

整合測試(較慢,謹慎使用):

  • 僅用於無法單元測試的功能(虛擬模組、完整建置管線)
  • 務必設定唯一的 outDir 以避免快取污染

完整模式和範例請見 testing.md。

何時不應使用此技能

  • 錯誤分類:請改用 triage 技能
  • GitHub Actions 分析:請改用 analyze-github-action-logs 技能
  • 簡單問題:直接提問,無需載入此技能

相關文檔

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

reyalka/astro

Analyze recent GitHub Actions workflow runs to identify patterns, mistakes, and improvements. Use when asked to "analyze workflow logs", "review action runs", or "analyze GitHub Actions".

reyalka/astro

Independently implement and validate an alternative solution for an Astro pull request. Use only for Factory's adversary blue team.

reyalka/astro

Qualify and compare red and blue solutions for an Astro pull request using Astro-specific merge and tie-break criteria. Use only for Factory's adversary purple team.

reyalka/astro

Perform a static, read-only code review of an Astro pull request or of a local branch, commit range, diff, patch, or working tree being prepared as a pull request. Determine whether the change satisfies its stated business requirements and is good enough to merge, using the PR description, linked requirement issues and roadmap items, and PR or issue discussions when available. Use this skill only for PR review or self-review, not issue triage or bug investigation. It reports only merge-relevant findings and never edits code or runs project code, tests, builds, checks, or scripts.

reyalka/astro

Write and update Astro pull requests with reviewer-friendly titles and high-signal bodies. Trigger whenever the user asks to create a PR, open a PR, draft a PR, update PR title/body, or write PR notes/summary/description.

reyalka/astro

Handle main-to-next merge tasks including conflict resolution, changeset cleanup, and CI fix-ups. Use when merging main into next.

reyalka/astro

How to write JSDoc (/** */) and inline (//) comments in the Astro codebase, for contributors reading the source — not end users. Use whenever writing or editing comments in .ts/.js source, including comments added incidentally while fixing bugs or building features. Does not cover the @docs-generated config/error reference.

相關技能