Agent skill · AI & Agents

ai-output-validation

Ensures all AI-generated output fields have proper validation. Auto-activates on "AI 輸出", "LLM", "Gemini", "GPT", "truncate", "截斷" keywords. Lesson learned: 2026-01-08 Quick Feedback, Report, Deep Analyze truncation bugs.

majiayu000github.com/majiayu000GitHub ↗
claude-codecan modify filesMIT
Install
npx skills add majiayu000/claude-skill-registry --skill ai-output-validation-youngger9765-career-ios-backend-2 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 3 KB
Bundled scripts: none
Version: 1.0
Allowed tools: ReadGrepBash
Path: skills/ai-llm/ai-output-validation-youngger9765-career-ios-backend-2/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# AI Output Validation - AI 輸出驗證 **Purpose**: 確保所有 AI 生成的欄位都有完整的驗證機制 **Lesson Learned**: 2026-01-08 三個截斷 Bug - Quick Feedback: `max_tokens=50` 太小,回傳 1-3 字 - Report: 硬截斷 `[:15]` 切斷句子中間 - Deep Analyze: 缺少 display_text/quick_suggestion 驗證 --- ## 核心原則 ### ❌ 錯誤做法 ```python # 硬截斷 - 會切斷句子 result["text"] = ai_response[:15] # max_tokens 太小 - AI 會截斷 response = await llm.generate(max_tokens=50) # 中文需要更多 tokens # 沒有驗證 - 不知道是否完整 return {"message": ai_response} ``` ### ✅ 正確做法 ```python # 1. 定義限制(基於 prompt 或資料範圍) MAX_CHARS = 15 MIN_CHARS = 7 # 2. 用 prompt 控制長度(讓 AI 自己處理) prompt = "請用 15 字以內回應..." # 3. 加大 max_tokens(避免 AI 被迫截斷) response = await llm.generate(max_tokens=500) # 4. 驗證並 fallback if len(text) < MIN_CHARS: logger.warning(f"Too short: {text}") text = FALLBACK_MESSAGE # 5. Log warning(不要硬截斷) if len(text) > MAX_CHARS: logger.warning(f"Over limit: {len(text)} chars") ``` --- ## 檢查清單 ### 每個 AI 生成欄位必須檢查: ``` □ 1. 定義 min_chars - 太短時 fallback 根據欄位用途決定最小字數 例:鼓勵文 7 字、建議 5 字 □ 2. 定義 max_chars - 超過時 log warning 根據 prompt 要求或 UI 限制 例:同心圓 15 字、display 20 字 □ 3. max_tokens 足夠大 - 避免 AI 被迫截斷 中文建議 500+(每字約 1-3 tokens) 檢查 finish_reason != MAX_TOKENS □ 4. 有 fallback 機制 - 太短或失敗時使用 預設訊息列表 random.choice(FALLBA

What's inside
Steps it walks through
  1. 核心原則
  2. ❌ 錯誤做法
  3. ✅ 正確做法
  4. 檢查清單
  5. 每個 AI 生成欄位必須檢查:
  6. 驗證範本
  7. 專案 AI 欄位參考表
  8. 診斷指令
  9. IMPORTANT
Ships with 1 file
  • metadata.json
Commands it runs
grep -rn "generate_text\|chat_completion\|_call_gemini" app/services/
grep -rn "max_tokens" app/services/
grep -rn "\[:.*\]" app/services/ | grep -v ".pyc"
grep -rn "min_chars\|max_chars\|MIN_\|MAX_" app/services/
More from claude-skill-registry
All skills →
About this skill
What does the ai-output-validation skill do?

Ensures all AI-generated output fields have proper validation. Auto-activates on "AI 輸出", "LLM", "Gemini", "GPT", "truncate", "截斷" keywords. Lesson learned: 2026-01-08 Quick Feedback, Report, Deep Analyze truncation bugs.

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill ai-output-validation-youngger9765-career-ios-backend-2 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going