skills/build-error-resolver/SKILL.md
建構與 TypeScript 錯誤修復專家。當建構失敗或出現類型錯誤時主動使用。僅修復建構/類型錯誤,最小化 diff,不做架構修改。專注於快速讓建構通過。
npx skillsauth add seikaikyo/dash-skills build-error-resolverInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
Security scan pending...
This skill is queued for security scanning. Results will appear when the scan completes.
在以下情況使用此 Skill:
npm run build 失敗npx tsc --noEmit 顯示錯誤# TypeScript 類型檢查 (無輸出)
npx tsc --noEmit
# 顯示所有錯誤
npx tsc --noEmit --pretty --incremental false
# 檢查特定檔案
npx tsc --noEmit path/to/file.ts
# Next.js 建構
npm run build
# ESLint 檢查
npx eslint . --ext .ts,.tsx,.js,.jsx
npx tsc --noEmit --pretty
// 錯誤: Parameter 'x' implicitly has an 'any' type
function add(x, y) { return x + y }
// 修復: 加上類型註解
function add(x: number, y: number): number { return x + y }
// 錯誤: Object is possibly 'undefined'
const name = user.name.toUpperCase()
// 修復: Optional chaining
const name = user?.name?.toUpperCase()
// 或: Null check
const name = user && user.name ? user.name.toUpperCase() : ''
// 錯誤: Property 'age' does not exist on type 'User'
interface User { name: string }
const user: User = { name: 'John', age: 30 }
// 修復: 新增屬性到 interface
interface User {
name: string
age?: number
}
// 錯誤: Cannot find module '@/lib/utils'
// 修復 1: 檢查 tsconfig paths
{
"compilerOptions": {
"paths": { "@/*": ["./src/*"] }
}
}
// 修復 2: 使用相對路徑
import { formatDate } from '../lib/utils'
// 修復 3: 安裝缺少的套件
npm install @/lib/utils
// 錯誤: Type 'string' is not assignable to type 'number'
const age: number = "30"
// 修復: 轉型
const age: number = parseInt("30", 10)
// 錯誤: Type 'T' is not assignable to type 'string'
function getLength<T>(item: T): number {
return item.length
}
// 修復: 加上限制
function getLength<T extends { length: number }>(item: T): number {
return item.length
}
// 錯誤: React Hook cannot be called conditionally
function MyComponent() {
if (condition) {
const [state, setState] = useState(0) // 錯誤!
}
}
// 修復: Hook 移到頂層
function MyComponent() {
const [state, setState] = useState(0)
if (!condition) return null
// 使用 state
}
// 錯誤: 'await' only allowed within async functions
function fetchData() {
const data = await fetch('/api/data')
}
// 修復: 加上 async
async function fetchData() {
const data = await fetch('/api/data')
}
// 錯誤: Cannot find module 'react'
// 修復: 安裝依賴
npm install react
npm install --save-dev @types/react
# 建構錯誤修復報告
**日期:** YYYY-MM-DD
**建構目標:** Next.js Production / TypeScript Check
**初始錯誤:** X
**已修復錯誤:** Y
**建構狀態:** 通過 / 失敗
## 已修復錯誤
### 1. [錯誤類別]
**位置:** `src/components/Card.tsx:45`
**錯誤訊息:**
Parameter 'market' implicitly has an 'any' type.
**修復:**
+function formatMarket(market: Market) {
-function formatMarket(market) {
**修改行數:** 1
## 驗證步驟
1. TypeScript 檢查通過: `npx tsc --noEmit`
2. Next.js 建構成功: `npm run build`
3. 無新錯誤產生
# 檢查錯誤
npx tsc --noEmit
# 清除快取重建
rm -rf .next node_modules/.cache
npm run build
# 安裝缺少的依賴
npm install
# 自動修復 ESLint
npx eslint . --fix
# 驗證 node_modules
rm -rf node_modules package-lock.json
npm install
npx tsc --noEmit 回傳 code 0npm run build 成功完成development
拋棄式 HTML mockup 比稿:產出 2 到 3 個設計立場不同的變體(密度 / 版式 / 強調軸,不是換色),各附取捨說明,最後給有立場的對比結論。適用:「畫個草圖」「比較 A 版 B 版」「先看方向再做」「給我看幾種做法」。要 production 元件或設計已定案時不適用。
tools
需求不明時的意圖萃取訪談:一次一題、每題附上自己的猜測、聽出「真正想要 vs 覺得應該要」,直到能預測使用者反應(約 95% 信心)才動工。適用:需求缺少對象 / 動機 / 成功標準 / 約束,或使用者點名「訪談我」「先確認一下」「我們確定嗎」。明確自足的指示、純資訊查詢、機械性操作不適用。
development
對非平凡決策啟動新鮮 context 對抗審查(找碴不背書),在修正還便宜的時候抓出錯誤方向。適用:高風險改動(production、資安敏感邏輯、不可逆操作)、不熟的程式碼、要宣稱「這樣是安全的 / 可行的」之前。機械性操作與一行修改不適用。
testing
Reference for writing and editing agent skills well — the vocabulary and principles that make a skill predictable. Consult when authoring, reviewing, or pruning a SKILL.md.