Communitygithub.com

delivery-gate

停止掛鉤,在 Claude 完成工作前強制執行品質檢查,阻擋未通過學習補捉與磁碟空間檢查的完成動作。

delivery-gate 是什麼?

Delivery-gate 是一個專為 Claude Code 設計的機械式停止掛鉤(Stop hook),用於在會話結束前強制執行三項確定性(deterministic)檢查:學習庫的時間戳是否當日更新、磁碟可用空間是否充足,以及 transcript 結尾是否含有合理化模式(rationalization patterns)。所有檢查均依賴檔案系統的 mtime、`shutil.disk_usage` 和正規表達式,完全不使用 AI 推論,因此結果客觀、可重複。 此工具特別適合需要在長期開發中養成學習紀錄習慣的團隊:當 Claude 完成複雜任務(編輯次數 >= 3)但未更新至少一個學習庫時,掛鉤會以 exit code 2 阻擋完成;磁碟空間低於 15GB 時同樣阻擋。合理化檢測僅發出警告,不阻擋,以避免誤判。它與同類工具 `self-audit`(內容品質閘門)、`verification-loop`(程式碼品質閘門)形成多層防禦,類似 CI pipeline 中的機械式閘門。支援 Python 3.8+,跨平台,無外部依賴,只需要將 Python 腳本複製到 `~/.claude/scripts/` 並在 `settings.json` 中註冊即可使用。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/delivery-gate

在你喜歡的 AI 中提問

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

說明文件

Delivery Gate — Claude Code 的機械式品質閘門

一個停止掛鉤,在 Claude 結束會話前檢查三件事,只使用確定性檢查 — 檔案修改時間戳、磁碟使用量與 transcript 文字上的正規表達式模式。不使用任何 AI 推論。

這與推理閘門(如 self-audit)不同:delivery-gate 檢查機器可驗證的事實;self-audit 則從四個推理維度檢查輸出品質。兩者共同形成縱深防禦:

  • delivery-gate:「學習庫今天有更新嗎?磁碟空間安全嗎?」
  • self-audit:「檔案內容正確、完整且誠實嗎?」

這與 CI pipeline 閘門的模式相同 — 自動化、確定性的檢查,驗證機器可讀的事實,而非信任自我報告的狀態。

檢查項目

檢查機制命中時的反應
合理化模式Transcript 結尾的正規表達式僅警告(永不阻擋)
學習庫過時5 個可設定路徑的 mtime部分過時時警告;>=3 個過時或增長日誌過時且任務複雜時阻擋
磁碟空間 < 50GBshutil.disk_usage警告
磁碟空間 < 15GBshutil.disk_usage阻擋(exit 2)

合理化檢測會對「暫時跳過測試」、「既存 bug」等模式發出警告 — 這些是思考可能被打斷的表面信號。它永遠不會單獨阻擋,因為正規表達式啟發式可能誤判。阻擋條件為:磁碟危急、>=3 個學習庫過時,或 growth-log 特別過時(均需複雜任務 >=3 次編輯)。

為什麼需要

Claude Code 內建的檢查涵蓋程式碼品質(建置 → 型別 → lint → 測試)。但存在另一種失敗模式:agent 產出可運作的程式碼,但會話衛生被忽視 — 學習未被記錄、合理化捷徑、磁碟空間悄然用盡。

經過許多「交付即遺忘」的會話後,人類並未成長。這個掛鉤強制養成習慣:複雜任務 → 必須更新學習庫。

安裝

cp quality-gate.py ~/.claude/scripts/

加入 ~/.claude/settings.json:

{
  "hooks": {
    "Stop": [{
      "hooks": [{
        "type": "command",
        "command": "python3 ~/.claude/scripts/quality-gate.py",
        "timeout": 5000
      }]
    }]
  }
}

學習庫

在專案的記憶體目錄中建立這些檔案。掛鉤會檢查至少有一個在今天被更新:

memory/
├── growth-log/          # 每日學習記錄(目錄)
├── decisions/log.md     # 決策日誌
├── output-index.md      # 會話輸出索引
├── ratings-tracker.md   # 技能評分隨著時間變化
└── tooling_capabilities.md  # 已知工具清單

可自訂 LIBS 字典以符合自己的檔案結構。

組態設定

編輯 quality-gate.py:

變數預設值用途
RATIONALIZE4 個模式用於檢測合理化的正規表達式模式
LIBS5 個庫檢查當日更新的檔案/目錄
COMPLEX_THRESHOLD3將編輯/寫入呼叫歸類為複雜任務的次數門檻
DISK_WARN_GB50低於此值時警告
DISK_CRIT_GB15低於此值時阻擋

範例

簡單會話 — 允許:

edit_count=1 (< 3, 非複雜) → exit 0

複雜任務,有記錄學習 — 允許:

edit_count=5 (複雜) → 檢查 LIBS → growth-log 今天已更新 → exit 0

複雜任務,未記錄學習 — 被阻擋:

edit_count=4 (複雜) → 檢查 LIBS → 全部 5 個過時 → exit 2
stderr: "Blocked: complex task completed but no learning captured today."

磁碟空間不足 — 被阻擋:

disk_free=12GB < 15GB 危急 → exit 2
stderr: "Blocked: disk space at 12GB (threshold: 15GB)."

限制

掛鉤強制的是更新學習庫的習慣,而非記錄內容的品質。如果 output-index.md 已更新但 growth-log 被跳過,掛鉤仍會通過(5 個庫中更新了 1 個)。這是刻意為之:機械式閘門檢查機器可驗證的事實。如需內容品質驗證,請搭配 self-audit 使用。

相容性

  • Python 3.8+(使用 from __future__ import annotations)
  • 跨平台:Windows、macOS、Linux
  • 零依賴,僅需標準函式庫

品質

此程式碼經過 4 輪自動化程式碼審查(CodeRabbit + Greptile),共發現並修復 9 個實際錯誤。

參見

  • self-audit — 推理品質閘門(完整性/一致性/根據性/誠實性)
  • verification-loop — 程式碼品質檢查(建置/型別/lint/測試)
  • gateguard — PreToolUse 安全閘門

Individual skills in this repo

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

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能