Skip to content

Adonis0123/adonis-skills / skills/goal-gate

goal-gate

Verified

Gate whether a coding-agent task benefits from a durable, verifiable contract, then draft, validate, start, continue, or close it for Codex, Grok, Claude Code, Cursor CLI, or an unknown host. Use for explicit goal or /goal requests and autonomous multi-checkpoint coding work with one checkable end state. Native Goal creation or mutation requires an explicit user or system request. Do not use for quick one-shot work, unrelated backlogs, OKRs, reminders, or token-budget-only changes.

FileKindSize
SKILL.mdskill md14.5 KB
agents/openai.yamlconfig386 B
evals/evals.jsonconfig46.5 KB
evals/trigger-eval.jsonconfig3.7 KB
references/copy-ready-goals.mdmarkdown10.9 KB
references/examples.mdmarkdown26.7 KB
references/runtime-actions.mdmarkdown10.8 KB
scripts/lint-goal-prompt.pyexecutablescript6.2 KB
scripts/test-lint-goal-prompt.pyexecutablescript10.8 KB

scripts/test-lint-goal-prompt.py

View on GitHub
#!/usr/bin/env python3
"""Minimal regression tests for lint-goal-prompt.py."""

from __future__ import annotations

import re
import subprocess
import sys
import tempfile
from pathlib import Path


SCRIPT_DIR = Path(__file__).resolve().parent
LINTER = SCRIPT_DIR / "lint-goal-prompt.py"


VALID_GOAL = """/goal 创建第一版本地个人记账 App MVP,实现添加、查看、编辑和删除一笔收支记录的核心流程。
验证:运行项目提供的最小相关检查,启动本地应用,在浏览器中完整走通核心流程,并用命令输出、日志或截图作为证据。
约束:不接入真实银行、支付、账号系统、云同步、生产部署或金融建议。
边界:只写入新项目目录,或只修改现有项目中与记账核心流程直接相关的文件。
执行编排:开始实现前根据任务复杂度、依赖关系、共享上下文、写入冲突和独立验证能力判断是否使用 subagent;主 agent 保留整体目标、结果审查和最终验证责任。
迭代策略:先做可运行核心流程,再根据检查结果和浏览器证据做最多 3 轮聚焦改进。
完成条件:本地核心记账流程可运行,验证证据已展示,检查通过或缺失配置已明确说明。
暂停条件:需要真实银行接口、账号凭证、付费服务、生产部署、法律/金融判断、敏感真实数据或产品范围决策时暂停。
"""


VALID_GOAL_EN = """/goal Implement docs/PLAN.md until every acceptance criterion is satisfied, the app builds, and pnpm test passes.
Verification: run pnpm test and pnpm build, surface exit codes, changed files, and screenshots if UI changed.
Constraints: stay within PLAN.md scope; do not push or commit unless asked.
Boundaries: only write inside src/ and docs/; never touch .env or CI config.
Execution strategy: Before implementation, assess dependencies, shared context, write overlap, and independent verification to decide whether subagents help; keep the main agent responsible for synthesis and final verification.
Iteration policy: at most 3 focused rounds; after 2 failures on the same error, read logs before retrying.
Stop when: all acceptance criteria hold and pnpm test passes with surfaced evidence.
Pause if: credentials, production data, or destructive actions are required.
"""


VALID_GOAL_EVAL_LOOP = """/goal Optimize prompts/support-agent.md until `pnpm eval:prompt -- --suite support-agent` reaches at least 0.92.
Verification: Run `pnpm eval:prompt -- --suite support-agent` after each focused change; surface the score, failing cases reviewed, and final diff summary.
Constraints: Keep prompt edits minimal; do not change eval fixtures, product behavior, or policy unless explicitly approved.
Boundaries: Write only prompts/support-agent.md; treat eval fixtures and runner code as read-only.
Execution strategy: Assess whether independent read-only eval analysis would reduce context pressure; delegate only when it does, serialize prompt edits, and keep final score/diff verification with the main agent.
Iteration policy: Run at most 5 focused edit/eval rounds; after two rounds with no score improvement, inspect failure clusters and change the hypothesis before retrying.
Stop when: The eval score reaches at least 0.92 with surfaced evidence, or no in-boundary prompt change can improve the remaining failures.
Pause if: Reaching the target requires changing policy, product behavior, eval fixtures, credentials, or another file outside the write boundary.
"""


CASES = [
    {
        "name": "valid-goal",
        "text": VALID_GOAL,
        "returncode": 0,
        "stderr_contains": "",
    },
    {
        "name": "valid-goal-english",
        "text": VALID_GOAL_EN,
        "returncode": 0,
        "stderr_contains": "",
    },
    {
        "name": "valid-eval-improvement-loop",
        "text": VALID_GOAL_EVAL_LOOP,
        "returncode": 0,
        "stderr_contains": "",
    },
    {
        "name": "reject-strategy-without-main-agent-ownership",
        "text": VALID_GOAL.replace(
            "执行编排:开始实现前根据任务复杂度、依赖关系、共享上下文、写入冲突和独立验证能力判断是否使用 subagent;主 agent 保留整体目标、结果审查和最终验证责任。",
            "执行编排:开始实现前根据任务复杂度、依赖关系、共享上下文、写入冲突和独立验证能力判断是否使用 subagent。",
            1,
        ),
        "returncode": 1,
        "stderr_contains": "execution strategy should keep the main agent accountable",
    },
    {
        "name": "reject-missing-execution-strategy",
        "text": VALID_GOAL.replace(
            "执行编排:开始实现前根据任务复杂度、依赖关系、共享上下文、写入冲突和独立验证能力判断是否使用 subagent;主 agent 保留整体目标、结果审查和最终验证责任。\n",
            "",
            1,
        ),
        "returncode": 1,
        "stderr_contains": "missing execution strategy",
    },
    {
        "name": "reject-forced-subagent-strategy",
        "text": VALID_GOAL.replace(
            "执行编排:开始实现前根据任务复杂度、依赖关系、共享上下文、写入冲突和独立验证能力判断是否使用 subagent;主 agent 保留整体目标、结果审查和最终验证责任。",
            "执行编排:任务较大,固定使用 subagent 并行执行。",
            1,
        ),
        "returncode": 1,
        "stderr_contains": "execution strategy should assess delegation",
    },
    {
        "name": "reject-chinese-command-prefix",
        "text": VALID_GOAL.replace("/goal", "/目标", 1),
        "returncode": 1,
        "stderr_contains": "use /goal",
    },
    {
        "name": "reject-placeholder",
        "text": VALID_GOAL.replace("创建第一版本地个人记账 App MVP", "[Outcome]", 1),
        "returncode": 1,
        "stderr_contains": "unresolved placeholder",
    },
    {
        "name": "reject-thin-verification",
        "text": VALID_GOAL.replace(
            "验证:运行项目提供的最小相关检查,启动本地应用,在浏览器中完整走通核心流程,并用命令输出、日志或截图作为证据。",
            "验证:确认可用。",
            1,
        ),
        "returncode": 1,
        "stderr_contains": "verification should name concrete evidence",
    },
]


# Required field bodies must be real content, including multi-line copy-ready
# blocks. A following label cannot supply the previous field's value.
FIELD_LABELS = [
    ("verification", "Verification", "验证"),
    ("constraints", "Constraints", "约束"),
    ("boundaries", "Boundaries", "边界"),
    ("execution strategy", "Execution strategy", "执行编排"),
    ("iteration policy", "Iteration policy", "迭代策略"),
    ("stop when", "Stop when", "完成条件"),
    ("pause if", "Pause if", "暂停条件"),
]
for field, english, chinese in FIELD_LABELS:
    for language, prompt, label in [("en", VALID_GOAL_EN, english), ("zh", VALID_GOAL, chinese)]:
        CASES.append({
            "name": f"reject-empty-{language}-{field.replace(' ', '-')}",
            "text": re.sub(rf"(?m)^{re.escape(label)}[::].*$", label + ":  ", prompt),
            "returncode": 1,
            "stderr_contains": f"empty {field}",
        })

for name, text, code, diagnostic in [
    ("valid-multiline-blocks", re.sub(r"(?m)^([^/\n]+[::]) +", r"\1\n  ", VALID_GOAL_EN), 0, ""),
    ("valid-indented-fenced-block", "```text\n" + "\n".join("  " + line for line in VALID_GOAL.splitlines()) + "\n```\n", 0, ""),
    ("valid-multiline-chinese", re.sub(r"(?m)^([^/\n]+[::])", r"\1\n  ", VALID_GOAL), 0, ""),
    ("valid-verification-code-block", VALID_GOAL_EN.replace("Verification: run pnpm test and pnpm build, surface exit codes, changed files, and screenshots if UI changed.", "Verification:\n```sh\npnpm test\npnpm build\n```"), 0, ""),
    ("reject-fence-only-pause", re.sub(r"(?m)^Pause if:.*$", "Pause if:\n```", VALID_GOAL_EN), 1, "empty pause if"),
    ("reject-doc-url-command", VALID_GOAL_EN.replace("/goal", "https://docs.example.test/goal", 1), 1, "missing command"),
    ("reject-prose-command", VALID_GOAL_EN.replace("/goal", "The command is /goal", 1), 1, "missing command"),
    ("reject-longer-command-token", VALID_GOAL_EN.replace("/goal", "/goalkeeper", 1), 1, "missing command"),
    ("reject-inline-label-only", VALID_GOAL_EN.replace("Constraints:", "Background mentions Constraints:", 1), 1, "missing constraints"),
]:
    CASES.append({"name": name, "text": text, "returncode": code, "stderr_contains": diagnostic})


for name, reference, code in [
    ("valid-markdown-plan-link", "[PLAN](docs/PLAN.md)", 0),
    ("valid-markdown-url", "[Acceptance criteria](https://example.test/spec#done)", 0),
    ("reject-link-todo-label", "[TODO](docs/PLAN.md)", 1),
    ("reject-link-placeholder-target", "[PLAN]([path])", 1),
    ("reject-link-angle-placeholder-target", "[PLAN](<file>)", 1),
    ("reject-link-todo-target", "[PLAN](TODO)", 1),
    ("reject-empty-link-target", "[PLAN]()", 1),
    ("reject-unfinished-link", "[PLAN](docs/PLAN.md", 1),
    ("reject-plain-bracket-placeholder", "[path]", 1),
]:
    CASES.append({
        "name": name,
        "text": VALID_GOAL_EN.replace("docs/PLAN.md", reference, 1),
        "returncode": code,
        "stderr_contains": "unresolved placeholder" if code else "",
    })


def run_case(tmp_dir: Path, case: dict[str, object]) -> list[str]:
    path = tmp_dir / f"{case['name']}.txt"
    path.write_text(str(case["text"]), encoding="utf-8")

    result = subprocess.run(
        [sys.executable, str(LINTER), str(path)],
        check=False,
        capture_output=True,
        text=True,
    )

    errors: list[str] = []
    expected_returncode = int(case["returncode"])
    if result.returncode != expected_returncode:
        errors.append(
            f"{case['name']}: expected return code {expected_returncode}, got {result.returncode}",
        )

    expected_stderr = str(case["stderr_contains"])
    if expected_stderr and expected_stderr not in result.stderr:
        errors.append(
            f"{case['name']}: expected stderr to contain {expected_stderr!r}, got {result.stderr!r}",
        )

    if not expected_stderr and result.stderr:
        errors.append(f"{case['name']}: expected empty stderr, got {result.stderr!r}")

    return errors


def main() -> int:
    if not LINTER.exists():
        print(f"Missing linter: {LINTER}", file=sys.stderr)
        return 2

    errors: list[str] = []
    with tempfile.TemporaryDirectory() as raw_tmp_dir:
        tmp_dir = Path(raw_tmp_dir)
        for case in CASES:
            errors.extend(run_case(tmp_dir, case))

    if errors:
        for error in errors:
            print(error, file=sys.stderr)
        return 1

    print(f"{len(CASES)} lint-goal-prompt regression tests passed.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall