Skip to content
Testing
Hook

Hooks

What ai-api-test-skill runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
ai-api-test-skill
1681 skill1 hook

Claude Code

$ npx -y skills add buer2233/ai-api-test-skill --agent claude-code

Where it lives

  • hooks/preflight_hook.pyGitHub
    Read the script
    # -*- coding: utf-8 -*-
    # Author: dengwanpeng
    
    """Claude Code PreToolUse hook:在 AI 调用 Skill 工具触发 api-test-E10 时,
    自动执行 tools/preflight_check.py,把输出通过 hookSpecificOutput.additionalContext
    注入 AI 上下文,等价于 SKILL.md 里原本的「前置必跑 0」。
    
    Hook I/O 协议(Claude Code 标准):
    - stdin:  JSON {tool_name, tool_input: {skill, args?}, cwd, session_id, ...}
    - stdout: JSON {hookSpecificOutput: {hookEventName, additionalContext}}
    - exit 0: 放行;exit 2: 阻断该工具调用
    
    ⚠️ 触发范围限制:仅在 AI 主动调 `Skill({skill: "api-test-E10"})` 时生效;
       被 `Read` / `@skill_path` / system-reminder 触发的 skill 加载不会进入这里。
    """
    
    import json
    import os
    import subprocess
    import sys
    
    HOOK_DIR = os.path.dirname(os.path.abspath(__file__))
    SKILL_ROOT = os.path.dirname(HOOK_DIR)
    PREFLIGHT_SCRIPT = os.path.join(SKILL_ROOT, "tools", "preflight_check.py")
    
    for _stream in (sys.stdout, sys.stderr):
        try:
            _stream.reconfigure(encoding="utf-8")
        except (AttributeError, ValueError):
            pass
    
    
    def main() -> int:
        try:
            payload = json.load(sys.stdin)
        except Exception:
            return 0
    
        tool_input = payload.get("tool_input") or {}
        skill_name = (tool_input.get("skill") or "").strip()
    
        # 只拦截 api-test-E10,避免影响其他 Skill。
        should_run = skill_name == "api-test-E10"
    
        if not should_run:
            return 0
    
        cwd = payload.get("cwd") or os.getcwd()
        env = os.environ.copy()
        env["PYTHONIOENCODING"] = "utf-8"
    
        try:
            result = subprocess.run(
                [sys.executable, PREFLIGHT_SCRIPT],
                cwd=cwd,
                text=True,
                encoding="utf-8",
                env=env,
                capture_output=True,
                timeout=120,
            )
        except Exception as e:
            # preflight 自身崩溃(脚本路径错 / 超时 / Python 缺失),不要阻断 skill
            err_ctx = f"[preflight_hook] 执行 preflight_check.py 失败: {e}"
            print(json.dumps({
                "hookSpecificOutput": {
                    "hookEventName": "PreToolUse",
                    "additionalContext": err_ctx,
                }
            }, ensure_ascii=False))
            return 0
    
        output_blob = (result.stdout or "") + (result.stderr or "")
        context_text = (
            "[preflight_check] 入口前置检查结果(由 hook 自动执行,等价于 SKILL.md 原前置必跑 0):\n"
            + output_blob.strip()
        )
        print(json.dumps({
            "hookSpecificOutput": {
                "hookEventName": "PreToolUse",
                "additionalContext": context_text,
            }
        }, ensure_ascii=False))
    
        # preflight 失败只把诊断注入上下文,不阻断 Skill 调用。
        if result.returncode != 0:
            return 0
    
        return 0
    
    
    if __name__ == "__main__":
        sys.exit(main())
    

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

@buer2233
Ships withai-api-test-skill

面向 Python + pytest + requests 接口自动化项目的 AI Skill:让 Codex / Claude Code 按固定门禁、固定流程、固定 pytest 闭环来新增和维护接口自动化用例,流程图参考:flow_chart/flow.md。 它不是一个普通的提示词模板,而是一套可随仓库分发的工程化 Skill:会先校验任务信息,再按“抓包 / 参考用例 / cURL / Java Controller / pytest 报错”选择路径,最后把接口方法、接口用例和测试验证收敛到同一套规范里。

Stars on GitHub

Momentum

stars in total
168
Star history of buer2233/ai-api-test-skill on GitHub, a chart by star-history.com

More plugins that ship hooks.

ww-w-ai-bkit
Plugin

ww-w-ai-bkit

A Claude Code plugin that checks AI-generated code against its design specs, with audit logs, auth, and database skills for bkend.ai projects. Useful for developers reviewing code that an AI assistant wrote.

44 skills+3606
@popup-studio-ai@popup-studio-ai
Install Plugin
accessibility-agents
Plugin

accessibility-agents

Catches accessibility problems while an AI coding assistant writes web interface code, so WCAG accessibility issues are caught before they ship. It also compares audits across commits to flag regressions and drafts an accessibility statement from the findings.

108 skills2 hooks429
@community-access@community-access
Install Plugin
swingerman-atdd
Plugin

swingerman-atdd

A methodology kit for Claude Code that drives feature work through acceptance test driven development, with spec-first artifacts, architecture checks, and a CRAP analyzer for risk-based refactor and test plans on changed code.

28 skills+3162
@swingerman@swingerman
Install Plugin
velocitai
Plugin

velocitai

Next-generation UI automation harness powered by Python & Playwright. Chat with AI Agents to seamlessly generate, architect, and execute enterprise-grade UI test code.

13 skills+2158
@danielsuo117@danielsuo117
Install Plugin
e2e-testing
Plugin

e2e-testing

Runs a disciplined, test-first workflow for building features and fixing bugs in Claude Code. It brainstorms and plans before coding, reviews finished work against the plan, and guides Playwright end-to-end tests for Next.js and React apps, so you stop skipping tests and debugging by guesswork.

9 skills2 hooks16
@burhankhatri@burhankhatri
Install Plugin

Questions about the hooks in ai-api-test-skill.

Which coding agents can use the hooks in ai-api-test-skill?
The hooks in ai-api-test-skill install in Claude Code and Cursor: each runs Claude Code hooks from .claude/settings.json, so copy the hooks there.