Communitygithub.com

delivery-gate

停止钩子,在质量检查通过前阻止 Claude 完成任务。检测合理化模式(表面文本启发式)、过时的学习日志(文件系统修改时间)和低磁盘空间。与自我审计互补,以机械方式强制养成学习记录习惯。当需要 Claude 在质量检查和实际通过学习记录之前被机械阻止时使用。

delivery-gate 是什么?

Delivery Gate 是一个用于 Claude Code 的机械质量门控停止钩子,它通过确定性检查(文件修改时间戳、磁盘使用率和转录文本上的正则表达式模式)在允许 Claude 完成任务前强制执行质量关卡,无需任何 AI 推理。它与 `self-audit`(推理质量门控)形成深度防御,分别检查机器可验证的事实和输出内容质量。该钩子检查三个关键方面:检测合理化模式(如“跳过测试”等表面信号,仅警告从不阻止)、跟踪学习库的新鲜度(通过 mtime 检查至少 5 个库之一是否在当天更新,当 3 个以上过时或 `growth-log` 特定过时加上复杂任务时触发阻止),以及在磁盘空间低于 50GB 时发出警告、低于 15GB 时阻止。它依赖于 Python 3.8+ 标准库,跨平台兼容(Windows、macOS、Linux),通过简单的 `cp` 命令和 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 结束会话前检查三个条件,仅使用确定性检查——文件修改时间戳、磁盘使用率和转录文本上的正则表达式模式。不依赖 AI 推理。

这与推理门控(如 self-audit)不同:delivery-gate 检查机器可验证的事实;self-audit 则在四个推理维度上检查输出质量。两者共同构成深度防御:

  • delivery-gate:“今天学习库被触碰了吗?磁盘空间安全吗?”
  • self-audit:“文件内容正确、完整且诚实吗?”

这与 CI 流水线门控模式相同——自动化的确定性检查验证机器可读的事实,而非相信自我报告的状态。

检查内容

检查项机制命中时处理
合理化模式对转录文本尾部进行正则匹配仅警告(从不阻止)
过时的学习库检查 5 个可配置路径的 mtime部分过时则警告;阻止条件:>=3 个过时 或 复杂任务 + growth-log 过时
磁盘空间 < 50GBshutil.disk_usage警告
磁盘空间 < 15GBshutil.disk_usage阻止(退出码 2)

合理化检测会警告诸如“跳过测试”、“预先存在的 bug”等模式——这些是思维可能被缩短的表面信号。它本身从不阻止,因为正则启发式可能误报。阻止条件为:磁盘临界、>=3 个学习库过时,或 growth-log 特定过时(均要求复杂任务 >=3 次编辑)。

为什么需要

Claude Code 的内置检查覆盖代码质量(构建→类型→lint→测试)。但存在另一种失败模式:代理生成了可运行代码,但会话卫生被忽视——未记录学习、合理化捷径、磁盘静默耗尽。

在“发布即忘”的多个会话中,人类并未成长。此钩子强制执行习惯:复杂任务 → 必须触碰学习库。

安装

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

添加到 ~/.claude/settings.json:

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

学习库

在项目的 memory 目录下创建这些文件。钩子检查当天是否至少有一个文件被更新:

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 个真实 bug。

参见

  • 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.

相关技能