[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C2HADGFKGXAZSNYMEBKCVS":3,"skill-same:01M6C2HADGFKGXAZSNYMEBKCVS":94},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":54,"linkOnly":55,"markdownContent":56,"markdownBody":57,"frontMatter":58,"refName":70,"commitSha":71,"skillDirectory":72,"forksCount":73,"repositoryHtmlUrl":74,"repositoryHomepageUrl":75,"ownerHtmlUrl":76,"ownerBlogUrl":77,"ownerDescription":78,"updatedAt":79,"install":80,"resources":93},"01M6C2HADGFKGXAZSNYMEBKCVS","infer-completion-criteria","推断任务完成标准","Infer measurable completion criteria for an agent-loop task from project docs, code, and AIWG standards when the user has not supplied --completion explicitly","当用户未显式提供 --completion 时，从项目文档、代码和 AIWG 标准中推断智能体循环（agent-loop）任务的可衡量完成标准。","jmagly\u002Faiwg","jmagly","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1159087?v=4","01M6C10AK8N2WCSQN11FYGTJWN","Joseph Magly","01M6C10AQ8A2RMED1Y1BSVY7NF",229,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fagent-loop\u002Fskills\u002Finfer-completion-criteria\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BSAA4FBTWZP6X98STEHG99","智能体开发","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53],"infer","infer completion criteria","interactive","project docs","when","for","type","project","efficiency","task","standards","user","docs","read","ralph","grep","haiku","loop","Bash","refactor","code","test","automation","2026-11-10 10:12:30",false,"---\nnamespace: aiwg\nname: infer-completion-criteria\naliases: [agent-loop-infer-completion, al-infer-completion, ralph-infer-completion]\nplatforms: [all]\ndescription: Infer measurable completion criteria for an agent-loop task from project docs, code, and AIWG standards when the user has not supplied --completion explicitly\ncommandHint:\n  argumentHint: '\"\u003Ctask description>\" [--task-type code|test|docs|refactor] [--non-interactive]'\n  allowedTools: \"Read, Glob, Grep, Bash\"\n  model: haiku\n  category: automation\n  modelRole: efficiency\n  modelTier: economy\n---\n\n# Infer Completion Criteria\n\n## HITL authorization checkpoints\n\nBefore any confirmation below, read and apply\n[agent-loop authorization checkpoints](..\u002F..\u002Fdocs\u002Fhitl-authorization.md).\nCall `aiwg config authorization check --action-file \"$ACTION_FILE\" --target \"$TARGET_REPO\"`\nfor host-classified effects. Only `auto-authorized` with a signed receipt skips\nthat workflow prompt; retain existing prompts\u002Frefusals otherwise. Platform\nprompts are never bypassed. Limits, regression and threat overrides still require review.\n\n## Purpose\n\nWhen a user starts an `agent-loop` task without supplying `--completion`, this skill derives a measurable, verifiable completion criterion from project state. The output must satisfy the `vague-discretion` rule: a concrete shell command or file-inspection check that returns pass\u002Ffail unambiguously.\n\nIteration is only as good as its gate. A loop with a vague gate (\"until it's done\") runs forever or exits prematurely. This skill is what turns \"agent-loop this\" into \"agent-loop this until `\u003Cmeasurable thing>`.\"\n\nThe canonical name for the iterative-loop addon is **agent-loop**. `ralph` is the legacy name for the executor skill, retained as an alias; `al` is a short form. The detection\u002Frouting skill is `agent-loop` (which delegates to this skill when criteria are missing); the executor is `ralph` (canonical name forthcoming). Everywhere this skill says \"agent-loop\" you can read \"ralph\" as the legacy equivalent.\n\n## When This Skill Runs\n\nThis skill is invoked by:\n\n- The `agent-loop` detection-and-routing skill when it parses a user request without explicit completion criteria\n- The `ralph` executor skill during Phase 1 initialization when `--completion` is omitted\n- The `agent-loop-ext` external-loop launcher during pre-launch resolution when `--completion` is omitted\n- Direct invocation via `aiwg discover \"infer completion\"` → `aiwg show skill infer-completion-criteria --body` when a user wants to preview the inferred criterion before committing to a loop\n\nThis skill does **not** run when `--completion` is explicit. The user's word is authoritative.\n\n## Inference Pipeline\n\nThe skill is a deterministic walk through five evidence layers, plus one synthesis step. Each layer contributes candidate criteria; the synthesis picks the strongest measurable one and explains the chain of evidence.\n\n### Layer 1 — The task verb\n\nParse the user's task description for an intent verb. Map to a default criterion class:\n\n| Verb \u002F phrase | Criterion class |\n|---|---|\n| \"fix tests\", \"make tests pass\", \"test failure\" | Test suite passes (exit 0) |\n| \"add tests\", \"increase coverage\", \"test coverage\" | Coverage threshold met |\n| \"fix types\", \"type errors\", \"migrate to typescript\" | Type checker exits 0 |\n| \"fix lint\", \"clean up warnings\", \"style\" | Linter exits 0 |\n| \"build\", \"make it compile\" | Build command exits 0 |\n| \"refactor\", \"extract\", \"rename\" | Tests still pass AND build still passes (regression gate) |\n| \"implement \u003CX>\", \"add feature \u003CX>\" | Tests for the new code exist and pass |\n| \"document\", \"add docs\", \"JSDoc\" | Coverage check on docstrings\u002FJSDoc presence |\n| \"fix bug\", \"resolve issue #N\" | Specific test for that bug passes AND existing suite still green |\n| \"migrate\", \"upgrade\" | Build + test + lint all green (no regression) |\n\nIf the verb is ambiguous, the skill falls back to \"regression gate\" (build + test + lint all green) as the safest default.\n\n### Layer 2 — Project conventions in CLAUDE.md \u002F AGENTS.md \u002F AIWG.md\n\nRead the project's context files. AIWG-managed projects often declare commands directly:\n\n```bash\n# Run tests\nnpm test\n\n# Type check\nnpx tsc --noEmit\n\n# Lint markdown\nnpm exec markdownlint-cli2 \"**\u002F*.md\"\n```\n\nExtract these as the canonical commands for their respective domains. The Development section of `CLAUDE.md` is the highest-trust source here — it's what the project's maintainers run.\n\nAlso scan for explicit completion-criterion conventions. Some projects state \"a commit is not finished until CI passes\" — that signals the CI command (or equivalent local invocation) is the gate.\n\n### Layer 3 — Package manifests and config\n\nInspect the project's manifest files to discover scripts and tools:\n\n| Manifest | Where to look |\n|---|---|\n| `package.json` | `scripts.test`, `scripts.lint`, `scripts.build`, `scripts.coverage`, `scripts.typecheck` |\n| `Cargo.toml` | implies `cargo test`, `cargo build`, `cargo clippy` |\n| `pyproject.toml` | `[tool.pytest]`, `[tool.ruff]`, `[tool.mypy]`, `scripts.*` |\n| `go.mod` | implies `go test .\u002F...`, `go vet .\u002F...`, `go build .\u002F...` |\n| `Gemfile` | implies `bundle exec rspec`, `bundle exec rubocop` |\n| `pom.xml` \u002F `build.gradle` | `mvn test`, `mvn verify`, `gradle test` |\n| `.tool-versions` \u002F `mise.toml` | language version pins inform which tool is canonical |\n\nWhen multiple scripts exist (e.g. `test`, `test:unit`, `test:integration`), prefer the script the project's own docs reference. If the docs don't reference any, prefer the most specific match to the task verb (e.g. for \"fix integration test\" → `test:integration`).\n\n### Layer 4 — CI configuration\n\nCI files encode the team's actual definition of \"passes\":\n\n| CI system | Scan |\n|---|---|\n| GitHub Actions | `.github\u002Fworkflows\u002F*.yml` — extract `run:` steps from non-deploy jobs |\n| Gitea Actions | `.gitea\u002Fworkflows\u002F*.yml` — same |\n| GitLab CI | `.gitlab-ci.yml` — extract `script:` from test\u002Flint jobs |\n| CircleCI | `.circleci\u002Fconfig.yml` |\n| Jenkins | `Jenkinsfile` |\n\nThe first non-trivial verification step in the primary workflow is the team's canonical \"done\" gate. If CI runs `npm test && npm run lint && npm run typecheck` in order, the inferred criterion is \"all three exit 0.\"\n\n### Layer 5 — AIWG artifacts\n\nIf the project has a `.aiwg\u002F` directory, scan for relevant context:\n\n- `.aiwg\u002Ftesting\u002Ftest-strategy.md` — declared verification approach\n- `.aiwg\u002Farchitecture\u002Fsoftware-architecture-doc.md` — architectural quality gates\n- `.aiwg\u002Fsecurity\u002Fsecurity-gates.md` — security-related criteria\n- `.aiwg\u002Fquality\u002Fcode-review-guide.md` — code quality bars\n- `.aiwg\u002Factivity.log` — recent operations that may indicate what \"done\" looked like for similar past tasks\n- `.aiwg\u002Fworking\u002F\u003Crelated-progress-files>.md` — prior task progress files; mine the \"Completion criteria\" sections\n\nIf the project has a related use case (`.aiwg\u002Frequirements\u002FUC-*.md`) whose ID is in the task description, pull that use case's acceptance criteria — those ARE the completion criteria.\n\n### Synthesis step\n\nCombine the layers into a single proposed criterion. The decision logic:\n\n1. If a use case in `.aiwg\u002Frequirements\u002F` matches the task, use its acceptance criteria verbatim. Done.\n2. Otherwise, take the verb-class default from Layer 1 and instantiate it using the canonical command from Layer 2 (CLAUDE.md) > Layer 4 (CI) > Layer 3 (manifest).\n3. If the task is in the \"regression gate\" class, AND the project's CI runs more than one verification, combine them: `command-A passes AND command-B passes AND command-C passes`.\n4. If no canonical command is found in any layer (unusual — typically only on empty-scaffold projects), fall back to:\n   - `\u003Cfile or change exists in git diff against HEAD~1>` — pure structural check\n   - And inform the user that a substantive verification command should be added.\n\n### Apply AIWG standards (vague-discretion)\n\nValidate the proposal against the `vague-discretion` rule:\n\n- Criterion must be expressible as a shell command (or shell pipeline) that exits 0 on pass, non-zero on fail.\n- Criterion must NOT use the words \"good enough\", \"thorough\", \"comprehensive\", \"complete\" without a measurable suffix.\n- Criterion must NOT be self-referential (\"the agent is satisfied\" — no).\n- Criterion must have an implicit or explicit `max-iterations` cap (ralph's default 10 is the floor; very large refactors may need 20).\n\nIf the proposal fails any of these, regenerate. If after two regenerations the proposal still fails, surface the problem to the user with the diagnostic (\"could not find a measurable verification command — please supply one explicitly\").\n\n## Output Contract\n\nThe skill emits a single block of structured output for the calling skill (`agent-loop` router, `ralph` executor, or `agent-loop-ext` launcher) to consume:\n\n```yaml\nproposed_completion:\n  criterion: \"npm test passes AND npx tsc --noEmit exits 0\"\n  verification_command: \"npm test && npx tsc --noEmit\"\n  rationale:\n    - \"Task verb 'refactor' triggers regression gate (Layer 1)\"\n    - \"package.json scripts.test = 'jest --coverage' (Layer 3)\"\n    - \"CLAUDE.md Development section references both npm test and npx tsc --noEmit (Layer 2)\"\n    - \".github\u002Fworkflows\u002Fci.yml runs both as required checks (Layer 4)\"\n  confidence: high  # high | medium | low\n  alternatives_considered:\n    - criterion: \"npm run lint exits 0\"\n      rejected_because: \"Lint is not in CI required checks for this repo\"\n  max_iterations_suggestion: 10\n  needs_human_confirmation: false  # true if confidence == low OR criterion is unusual\n```\n\nWhen the skill runs in non-interactive mode (via `aiwg al --auto-criteria` or the equivalent on `agent-loop` \u002F `agent-loop-ext`), `needs_human_confirmation: false` proceeds directly. Otherwise the consuming skill (the `agent-loop` router or the `ralph` \u002F `agent-loop-ext` executor) shows the proposal to the user and confirms.\n\n## Interaction With The User\n\nIn interactive mode, after running the pipeline, present the proposal:\n\n```\nNo --completion criteria was provided. I inferred:\n\n  Criterion: npm test passes AND npx tsc --noEmit exits 0\n  Verification: `npm test && npx tsc --noEmit`\n\nEvidence:\n  - Task verb \"refactor\" → regression gate\n  - package.json scripts.test = jest --coverage\n  - CLAUDE.md Development section references both checks\n  - .github\u002Fworkflows\u002Fci.yml requires both\n\nProceed with this criterion? [Y\u002Fn\u002Fedit]\n```\n\nUser options:\n- `Y` (default): start the loop with the inferred criterion\n- `n`: abort and request the user supply `--completion` explicitly\n- `edit`: accept a manual edit to the criterion before proceeding\n\nUse the platform's native interaction tool when available (per `native-ux-tools` rule). On Claude Code, that means `AskUserQuestion`.\n\n## When Inference Should NOT Run\n\n- `--completion` is explicit → use the user's criterion, don't second-guess\n- `--no-infer-completion` flag is passed → fail fast with a helpful error if `--completion` is also missing\n- The task description is itself a criterion (e.g. \"make `npx tsc --noEmit` pass\") → extract the command from the task, don't re-infer\n\n## Edge Cases\n\n| Case | Handling |\n|---|---|\n| No `package.json`, no manifest, no CI | Scan project root for any executable test runner (`pytest`, `go test`, `cargo test`, `make test`, `Makefile` target `test`). Fall back to the structural check if none found. |\n| Multiple test commands (`test:unit`, `test:integration`, `test:e2e`) | Prefer the one nearest to the task scope. If task mentions \"unit\", use `test:unit`. If the task is broad, prefer the union via `&&`. |\n| CI runs tests on multiple OS\u002FNode versions | Use the local invocation (`npm test`), not the matrix runner. The matrix is a deploy concern. |\n| Monorepo with multiple packages | Detect from `pnpm-workspace.yaml` \u002F `lerna.json` \u002F `turbo.json` \u002F workspaces field. If the task scope is one package, infer that package's commands. If the task spans the monorepo, use the top-level `test` script. |\n| Project has no tests at all | This is a finding. The inferred criterion should be \"tests exist for the new code AND those tests pass.\" Surface to the user that the project lacks a baseline test suite — that's important context for the loop's expectations. |\n| Project's tests are currently broken (the task IS to fix them) | Set the criterion to the passing condition. The whole point of the loop is to get from current red state to green. |\n| Conflict between layers (CLAUDE.md says X, CI says Y) | Prefer CLAUDE.md (closer to the maintainer's intent). Note the discrepancy in the rationale. |\n\n## Interaction With Other AIWG Rules\n\n| Rule | How this skill respects it |\n|---|---|\n| `vague-discretion` | The whole point — produces measurable, command-form criteria |\n| `instruction-comprehension` | Reads the task description carefully; doesn't override explicit user instructions |\n| `research-before-decision` | Layer-walk IS research; doesn't propose criteria without evidence |\n| `human-authorization` | Confirms with user before starting loop (unless `--auto-criteria` explicitly granted) |\n| `auto-compact-continue` | The inferred criterion IS what the loop continues toward; no \"should I keep working\" prompts |\n| `cli-secondary` | Uses `aiwg discover` to find related skills if the task verb is unusual |\n\n## Examples\n\n### Example 1: Simple test task on a TypeScript project\n\n```\n$ agent-loop \"fix the failing auth tests\"   # or: aiwg al \u002F aiwg ralph (legacy)\n\nInferring completion criteria...\n  Layer 1 verb: \"fix tests\" → test-pass class\n  Layer 2 CLAUDE.md: \"npm test\" is the canonical test command\n  Layer 3 package.json: scripts.test = \"jest\"\n  Layer 4 CI: .github\u002Fworkflows\u002Fci.yml runs `npm test`\n  Layer 5: no related use case found\n\nProposed criterion: npm test passes (exit 0)\nVerification: `npm test`\nConfidence: high\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 2: Refactor with no tests\n\n```\n$ agent-loop \"extract auth logic into a separate module\"\n\nInferring completion criteria...\n  Layer 1 verb: \"extract\" → regression gate\n  Layer 2 CLAUDE.md: no Development section\n  Layer 3 package.json: scripts.test = \"echo 'no tests'\" (degenerate)\n  Layer 4 CI: no workflows found\n  Layer 5: no related use case found\n\nWarning: project has no functional test suite or CI configuration.\nFalling back to structural verification.\n\nProposed criterion: The new module exists, the original code references it,\n                    AND `npx tsc --noEmit` still exits 0\nVerification: `test -f src\u002Fauth\u002Findex.ts && grep -q 'from.*src\u002Fauth' src\u002Fmain.ts && npx tsc --noEmit`\nConfidence: low\n\nThis is a weak gate. Consider supplying --completion explicitly\nor adding a test suite first.\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 3: Task with an explicit use case reference\n\n```\n$ agent-loop \"implement UC-AUTH-001\"\n\nInferring completion criteria...\n  Layer 1 verb: \"implement\" → tests-exist class\n  Layer 5: found .aiwg\u002Frequirements\u002FUC-AUTH-001-user-login.md\n\nUsing acceptance criteria from UC-AUTH-001:\n  - [ ] User can log in with valid email\u002Fpassword\n  - [ ] Invalid credentials show clear error message\n  - [ ] Account locks after 5 failed attempts\n  - [ ] Login completes within 2 seconds\n\nProposed criterion: All acceptance criteria from UC-AUTH-001 verified by tests,\n                    AND `npm test -- --testPathPattern=auth` passes\nVerification: `npm test -- --testPathPattern=auth`\nConfidence: high (acceptance criteria are explicit)\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 4: Refusal case\n\n```\n$ agent-loop \"make the code better\"\n\nInferring completion criteria...\n  Layer 1 verb: \"make better\" → AMBIGUOUS, no clear criterion class\n  Layer 5: no related use case\n\nCannot infer measurable criteria for this task.\n\n\"Make the code better\" is vague (per AIWG vague-discretion rule).\nA loop with no measurable gate runs forever or exits prematurely.\n\nPlease supply --completion with a concrete check, e.g.:\n  --completion \"npm test passes AND npm run lint exits 0\"\n  --completion \"all functions in src\u002Futils\u002F have JSDoc\"\n  --completion \"complexity score from eslint \u003C 10 for all files\"\n\nOr rephrase the task with a concrete intent:\n  agent-loop \"reduce cyclomatic complexity in src\u002Futils\u002F\"\n  agent-loop \"add JSDoc to all exported functions in src\u002Fapi\u002F\"\n```\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fvague-discretion.md — Measurable criteria requirement\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Layer-walk research pattern\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Finstruction-comprehension.md — Don't override explicit user criteria\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fauto-compact-continue.md — Criterion IS what the loop continues toward\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fagent-loop\u002FSKILL.md — The detection\u002Frouting skill that delegates here when `--completion` is missing\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fralph\u002FSKILL.md — The legacy executor skill that consumes this output (`ralph` is legacy for `agent-loop`'s executor)\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fagent-loop-ext\u002FSKILL.md — The crash-resilient external loop, same delegation pattern\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fagents\u002Fralph-verifier.md — Runs the verification command this skill proposes\n","# Infer Completion Criteria\n\n## HITL authorization checkpoints\n\nBefore any confirmation below, read and apply\n[agent-loop authorization checkpoints](..\u002F..\u002Fdocs\u002Fhitl-authorization.md).\nCall `aiwg config authorization check --action-file \"$ACTION_FILE\" --target \"$TARGET_REPO\"`\nfor host-classified effects. Only `auto-authorized` with a signed receipt skips\nthat workflow prompt; retain existing prompts\u002Frefusals otherwise. Platform\nprompts are never bypassed. Limits, regression and threat overrides still require review.\n\n## Purpose\n\nWhen a user starts an `agent-loop` task without supplying `--completion`, this skill derives a measurable, verifiable completion criterion from project state. The output must satisfy the `vague-discretion` rule: a concrete shell command or file-inspection check that returns pass\u002Ffail unambiguously.\n\nIteration is only as good as its gate. A loop with a vague gate (\"until it's done\") runs forever or exits prematurely. This skill is what turns \"agent-loop this\" into \"agent-loop this until `\u003Cmeasurable thing>`.\"\n\nThe canonical name for the iterative-loop addon is **agent-loop**. `ralph` is the legacy name for the executor skill, retained as an alias; `al` is a short form. The detection\u002Frouting skill is `agent-loop` (which delegates to this skill when criteria are missing); the executor is `ralph` (canonical name forthcoming). Everywhere this skill says \"agent-loop\" you can read \"ralph\" as the legacy equivalent.\n\n## When This Skill Runs\n\nThis skill is invoked by:\n\n- The `agent-loop` detection-and-routing skill when it parses a user request without explicit completion criteria\n- The `ralph` executor skill during Phase 1 initialization when `--completion` is omitted\n- The `agent-loop-ext` external-loop launcher during pre-launch resolution when `--completion` is omitted\n- Direct invocation via `aiwg discover \"infer completion\"` → `aiwg show skill infer-completion-criteria --body` when a user wants to preview the inferred criterion before committing to a loop\n\nThis skill does **not** run when `--completion` is explicit. The user's word is authoritative.\n\n## Inference Pipeline\n\nThe skill is a deterministic walk through five evidence layers, plus one synthesis step. Each layer contributes candidate criteria; the synthesis picks the strongest measurable one and explains the chain of evidence.\n\n### Layer 1 — The task verb\n\nParse the user's task description for an intent verb. Map to a default criterion class:\n\n| Verb \u002F phrase | Criterion class |\n|---|---|\n| \"fix tests\", \"make tests pass\", \"test failure\" | Test suite passes (exit 0) |\n| \"add tests\", \"increase coverage\", \"test coverage\" | Coverage threshold met |\n| \"fix types\", \"type errors\", \"migrate to typescript\" | Type checker exits 0 |\n| \"fix lint\", \"clean up warnings\", \"style\" | Linter exits 0 |\n| \"build\", \"make it compile\" | Build command exits 0 |\n| \"refactor\", \"extract\", \"rename\" | Tests still pass AND build still passes (regression gate) |\n| \"implement \u003CX>\", \"add feature \u003CX>\" | Tests for the new code exist and pass |\n| \"document\", \"add docs\", \"JSDoc\" | Coverage check on docstrings\u002FJSDoc presence |\n| \"fix bug\", \"resolve issue #N\" | Specific test for that bug passes AND existing suite still green |\n| \"migrate\", \"upgrade\" | Build + test + lint all green (no regression) |\n\nIf the verb is ambiguous, the skill falls back to \"regression gate\" (build + test + lint all green) as the safest default.\n\n### Layer 2 — Project conventions in CLAUDE.md \u002F AGENTS.md \u002F AIWG.md\n\nRead the project's context files. AIWG-managed projects often declare commands directly:\n\n```bash\n# Run tests\nnpm test\n\n# Type check\nnpx tsc --noEmit\n\n# Lint markdown\nnpm exec markdownlint-cli2 \"**\u002F*.md\"\n```\n\nExtract these as the canonical commands for their respective domains. The Development section of `CLAUDE.md` is the highest-trust source here — it's what the project's maintainers run.\n\nAlso scan for explicit completion-criterion conventions. Some projects state \"a commit is not finished until CI passes\" — that signals the CI command (or equivalent local invocation) is the gate.\n\n### Layer 3 — Package manifests and config\n\nInspect the project's manifest files to discover scripts and tools:\n\n| Manifest | Where to look |\n|---|---|\n| `package.json` | `scripts.test`, `scripts.lint`, `scripts.build`, `scripts.coverage`, `scripts.typecheck` |\n| `Cargo.toml` | implies `cargo test`, `cargo build`, `cargo clippy` |\n| `pyproject.toml` | `[tool.pytest]`, `[tool.ruff]`, `[tool.mypy]`, `scripts.*` |\n| `go.mod` | implies `go test .\u002F...`, `go vet .\u002F...`, `go build .\u002F...` |\n| `Gemfile` | implies `bundle exec rspec`, `bundle exec rubocop` |\n| `pom.xml` \u002F `build.gradle` | `mvn test`, `mvn verify`, `gradle test` |\n| `.tool-versions` \u002F `mise.toml` | language version pins inform which tool is canonical |\n\nWhen multiple scripts exist (e.g. `test`, `test:unit`, `test:integration`), prefer the script the project's own docs reference. If the docs don't reference any, prefer the most specific match to the task verb (e.g. for \"fix integration test\" → `test:integration`).\n\n### Layer 4 — CI configuration\n\nCI files encode the team's actual definition of \"passes\":\n\n| CI system | Scan |\n|---|---|\n| GitHub Actions | `.github\u002Fworkflows\u002F*.yml` — extract `run:` steps from non-deploy jobs |\n| Gitea Actions | `.gitea\u002Fworkflows\u002F*.yml` — same |\n| GitLab CI | `.gitlab-ci.yml` — extract `script:` from test\u002Flint jobs |\n| CircleCI | `.circleci\u002Fconfig.yml` |\n| Jenkins | `Jenkinsfile` |\n\nThe first non-trivial verification step in the primary workflow is the team's canonical \"done\" gate. If CI runs `npm test && npm run lint && npm run typecheck` in order, the inferred criterion is \"all three exit 0.\"\n\n### Layer 5 — AIWG artifacts\n\nIf the project has a `.aiwg\u002F` directory, scan for relevant context:\n\n- `.aiwg\u002Ftesting\u002Ftest-strategy.md` — declared verification approach\n- `.aiwg\u002Farchitecture\u002Fsoftware-architecture-doc.md` — architectural quality gates\n- `.aiwg\u002Fsecurity\u002Fsecurity-gates.md` — security-related criteria\n- `.aiwg\u002Fquality\u002Fcode-review-guide.md` — code quality bars\n- `.aiwg\u002Factivity.log` — recent operations that may indicate what \"done\" looked like for similar past tasks\n- `.aiwg\u002Fworking\u002F\u003Crelated-progress-files>.md` — prior task progress files; mine the \"Completion criteria\" sections\n\nIf the project has a related use case (`.aiwg\u002Frequirements\u002FUC-*.md`) whose ID is in the task description, pull that use case's acceptance criteria — those ARE the completion criteria.\n\n### Synthesis step\n\nCombine the layers into a single proposed criterion. The decision logic:\n\n1. If a use case in `.aiwg\u002Frequirements\u002F` matches the task, use its acceptance criteria verbatim. Done.\n2. Otherwise, take the verb-class default from Layer 1 and instantiate it using the canonical command from Layer 2 (CLAUDE.md) > Layer 4 (CI) > Layer 3 (manifest).\n3. If the task is in the \"regression gate\" class, AND the project's CI runs more than one verification, combine them: `command-A passes AND command-B passes AND command-C passes`.\n4. If no canonical command is found in any layer (unusual — typically only on empty-scaffold projects), fall back to:\n   - `\u003Cfile or change exists in git diff against HEAD~1>` — pure structural check\n   - And inform the user that a substantive verification command should be added.\n\n### Apply AIWG standards (vague-discretion)\n\nValidate the proposal against the `vague-discretion` rule:\n\n- Criterion must be expressible as a shell command (or shell pipeline) that exits 0 on pass, non-zero on fail.\n- Criterion must NOT use the words \"good enough\", \"thorough\", \"comprehensive\", \"complete\" without a measurable suffix.\n- Criterion must NOT be self-referential (\"the agent is satisfied\" — no).\n- Criterion must have an implicit or explicit `max-iterations` cap (ralph's default 10 is the floor; very large refactors may need 20).\n\nIf the proposal fails any of these, regenerate. If after two regenerations the proposal still fails, surface the problem to the user with the diagnostic (\"could not find a measurable verification command — please supply one explicitly\").\n\n## Output Contract\n\nThe skill emits a single block of structured output for the calling skill (`agent-loop` router, `ralph` executor, or `agent-loop-ext` launcher) to consume:\n\n```yaml\nproposed_completion:\n  criterion: \"npm test passes AND npx tsc --noEmit exits 0\"\n  verification_command: \"npm test && npx tsc --noEmit\"\n  rationale:\n    - \"Task verb 'refactor' triggers regression gate (Layer 1)\"\n    - \"package.json scripts.test = 'jest --coverage' (Layer 3)\"\n    - \"CLAUDE.md Development section references both npm test and npx tsc --noEmit (Layer 2)\"\n    - \".github\u002Fworkflows\u002Fci.yml runs both as required checks (Layer 4)\"\n  confidence: high  # high | medium | low\n  alternatives_considered:\n    - criterion: \"npm run lint exits 0\"\n      rejected_because: \"Lint is not in CI required checks for this repo\"\n  max_iterations_suggestion: 10\n  needs_human_confirmation: false  # true if confidence == low OR criterion is unusual\n```\n\nWhen the skill runs in non-interactive mode (via `aiwg al --auto-criteria` or the equivalent on `agent-loop` \u002F `agent-loop-ext`), `needs_human_confirmation: false` proceeds directly. Otherwise the consuming skill (the `agent-loop` router or the `ralph` \u002F `agent-loop-ext` executor) shows the proposal to the user and confirms.\n\n## Interaction With The User\n\nIn interactive mode, after running the pipeline, present the proposal:\n\n```\nNo --completion criteria was provided. I inferred:\n\n  Criterion: npm test passes AND npx tsc --noEmit exits 0\n  Verification: `npm test && npx tsc --noEmit`\n\nEvidence:\n  - Task verb \"refactor\" → regression gate\n  - package.json scripts.test = jest --coverage\n  - CLAUDE.md Development section references both checks\n  - .github\u002Fworkflows\u002Fci.yml requires both\n\nProceed with this criterion? [Y\u002Fn\u002Fedit]\n```\n\nUser options:\n- `Y` (default): start the loop with the inferred criterion\n- `n`: abort and request the user supply `--completion` explicitly\n- `edit`: accept a manual edit to the criterion before proceeding\n\nUse the platform's native interaction tool when available (per `native-ux-tools` rule). On Claude Code, that means `AskUserQuestion`.\n\n## When Inference Should NOT Run\n\n- `--completion` is explicit → use the user's criterion, don't second-guess\n- `--no-infer-completion` flag is passed → fail fast with a helpful error if `--completion` is also missing\n- The task description is itself a criterion (e.g. \"make `npx tsc --noEmit` pass\") → extract the command from the task, don't re-infer\n\n## Edge Cases\n\n| Case | Handling |\n|---|---|\n| No `package.json`, no manifest, no CI | Scan project root for any executable test runner (`pytest`, `go test`, `cargo test`, `make test`, `Makefile` target `test`). Fall back to the structural check if none found. |\n| Multiple test commands (`test:unit`, `test:integration`, `test:e2e`) | Prefer the one nearest to the task scope. If task mentions \"unit\", use `test:unit`. If the task is broad, prefer the union via `&&`. |\n| CI runs tests on multiple OS\u002FNode versions | Use the local invocation (`npm test`), not the matrix runner. The matrix is a deploy concern. |\n| Monorepo with multiple packages | Detect from `pnpm-workspace.yaml` \u002F `lerna.json` \u002F `turbo.json` \u002F workspaces field. If the task scope is one package, infer that package's commands. If the task spans the monorepo, use the top-level `test` script. |\n| Project has no tests at all | This is a finding. The inferred criterion should be \"tests exist for the new code AND those tests pass.\" Surface to the user that the project lacks a baseline test suite — that's important context for the loop's expectations. |\n| Project's tests are currently broken (the task IS to fix them) | Set the criterion to the passing condition. The whole point of the loop is to get from current red state to green. |\n| Conflict between layers (CLAUDE.md says X, CI says Y) | Prefer CLAUDE.md (closer to the maintainer's intent). Note the discrepancy in the rationale. |\n\n## Interaction With Other AIWG Rules\n\n| Rule | How this skill respects it |\n|---|---|\n| `vague-discretion` | The whole point — produces measurable, command-form criteria |\n| `instruction-comprehension` | Reads the task description carefully; doesn't override explicit user instructions |\n| `research-before-decision` | Layer-walk IS research; doesn't propose criteria without evidence |\n| `human-authorization` | Confirms with user before starting loop (unless `--auto-criteria` explicitly granted) |\n| `auto-compact-continue` | The inferred criterion IS what the loop continues toward; no \"should I keep working\" prompts |\n| `cli-secondary` | Uses `aiwg discover` to find related skills if the task verb is unusual |\n\n## Examples\n\n### Example 1: Simple test task on a TypeScript project\n\n```\n$ agent-loop \"fix the failing auth tests\"   # or: aiwg al \u002F aiwg ralph (legacy)\n\nInferring completion criteria...\n  Layer 1 verb: \"fix tests\" → test-pass class\n  Layer 2 CLAUDE.md: \"npm test\" is the canonical test command\n  Layer 3 package.json: scripts.test = \"jest\"\n  Layer 4 CI: .github\u002Fworkflows\u002Fci.yml runs `npm test`\n  Layer 5: no related use case found\n\nProposed criterion: npm test passes (exit 0)\nVerification: `npm test`\nConfidence: high\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 2: Refactor with no tests\n\n```\n$ agent-loop \"extract auth logic into a separate module\"\n\nInferring completion criteria...\n  Layer 1 verb: \"extract\" → regression gate\n  Layer 2 CLAUDE.md: no Development section\n  Layer 3 package.json: scripts.test = \"echo 'no tests'\" (degenerate)\n  Layer 4 CI: no workflows found\n  Layer 5: no related use case found\n\nWarning: project has no functional test suite or CI configuration.\nFalling back to structural verification.\n\nProposed criterion: The new module exists, the original code references it,\n                    AND `npx tsc --noEmit` still exits 0\nVerification: `test -f src\u002Fauth\u002Findex.ts && grep -q 'from.*src\u002Fauth' src\u002Fmain.ts && npx tsc --noEmit`\nConfidence: low\n\nThis is a weak gate. Consider supplying --completion explicitly\nor adding a test suite first.\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 3: Task with an explicit use case reference\n\n```\n$ agent-loop \"implement UC-AUTH-001\"\n\nInferring completion criteria...\n  Layer 1 verb: \"implement\" → tests-exist class\n  Layer 5: found .aiwg\u002Frequirements\u002FUC-AUTH-001-user-login.md\n\nUsing acceptance criteria from UC-AUTH-001:\n  - [ ] User can log in with valid email\u002Fpassword\n  - [ ] Invalid credentials show clear error message\n  - [ ] Account locks after 5 failed attempts\n  - [ ] Login completes within 2 seconds\n\nProposed criterion: All acceptance criteria from UC-AUTH-001 verified by tests,\n                    AND `npm test -- --testPathPattern=auth` passes\nVerification: `npm test -- --testPathPattern=auth`\nConfidence: high (acceptance criteria are explicit)\n\nProceed? [Y\u002Fn\u002Fedit]\n```\n\n### Example 4: Refusal case\n\n```\n$ agent-loop \"make the code better\"\n\nInferring completion criteria...\n  Layer 1 verb: \"make better\" → AMBIGUOUS, no clear criterion class\n  Layer 5: no related use case\n\nCannot infer measurable criteria for this task.\n\n\"Make the code better\" is vague (per AIWG vague-discretion rule).\nA loop with no measurable gate runs forever or exits prematurely.\n\nPlease supply --completion with a concrete check, e.g.:\n  --completion \"npm test passes AND npm run lint exits 0\"\n  --completion \"all functions in src\u002Futils\u002F have JSDoc\"\n  --completion \"complexity score from eslint \u003C 10 for all files\"\n\nOr rephrase the task with a concrete intent:\n  agent-loop \"reduce cyclomatic complexity in src\u002Futils\u002F\"\n  agent-loop \"add JSDoc to all exported functions in src\u002Fapi\u002F\"\n```\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fvague-discretion.md — Measurable criteria requirement\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Layer-walk research pattern\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Finstruction-comprehension.md — Don't override explicit user criteria\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fauto-compact-continue.md — Criterion IS what the loop continues toward\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fagent-loop\u002FSKILL.md — The detection\u002Frouting skill that delegates here when `--completion` is missing\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fralph\u002FSKILL.md — The legacy executor skill that consumes this output (`ralph` is legacy for `agent-loop`'s executor)\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fskills\u002Fagent-loop-ext\u002FSKILL.md — The crash-resilient external loop, same delegation pattern\n- @$AIWG_ROOT\u002F${CLAUDE_PLUGIN_ROOT}\u002Fagents\u002Fralph-verifier.md — Runs the verification command this skill proposes\n",{"name":5,"aliases":59,"namespace":63,"platforms":64,"commandHint":66,"description":7},[60,61,62],"agent-loop-infer-completion","al-infer-completion","ralph-infer-completion","aiwg",[65],"all",{"model":47,"category":53,"modelRole":39,"modelTier":67,"allowedTools":68,"argumentHint":69},"economy","Read, Glob, Grep, Bash","\"\u003Ctask description>\" [--task-type code|test|docs|refactor] [--non-interactive]","main","6754967c344ccb087a8de06972f55a41067b291b","agentic\u002Fcode\u002Fplugins\u002Fagent-loop\u002Fskills\u002Finfer-completion-criteria",36,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg","https:\u002F\u002Faiwg.io","https:\u002F\u002Fgithub.com\u002Fjmagly","https:\u002F\u002Fintegrolabs.io","ml\u002Fai, industrial automation, safety\u002Fsecurity, ssi\r\n\r\nmagly.net\r\nintegrolabs.io\r\naiwg.io\r\nfortemi.com\r\npagenary.com\r\nbytecask.com","2026-11-14 10:46:34",{"source":9,"skillName":5,"commands":81,"prompt":91,"zipAvailable":92},[82,85,88],{"tool":83,"command":84},"npx","npx skills add jmagly\u002Faiwg --skill infer-completion-criteria",{"tool":86,"command":87},"bunx","bunx skills add jmagly\u002Faiwg --skill infer-completion-criteria",{"tool":89,"command":90},"pnpm","pnpm dlx skills add jmagly\u002Faiwg --skill infer-completion-criteria","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fagent-loop\u002Fskills\u002Finfer-completion-criteria\u002FSKILL.md",true,[],[95,103,108,133,153,158],{"skillNo":96,"name":97,"nameZh":17,"description":98,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":102},"01M78KW7PZJ9YQZQMW84SN2YD4","plugin-search","Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Futils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":104,"name":97,"nameZh":17,"description":98,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":102},"01M78KSEZS9ZNNFESY9ANW22S0","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":17,"description":111,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":54},"01M70QA0BSYJ49EES9V4RE8QH1","host-hardening","Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[115,116,117,118,119,44,120,121,122,123,124,125,126,49,127,128,129,130,131,132],"hardening","host","host hardening","verification","secrets","request","remediation","recommendations","audit","plan","port","bind","access","only","retention","re","never","firewall",{"skillNo":134,"name":135,"nameZh":17,"description":136,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":54},"01M70PNT2Z4HMZPRBTAF6073NN","exposure-analysis","Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fforensics\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[140,141,142,143,144,145,44,146,125,131,49,147,116,148,128,149,150,132,151,152],"analysis","exposure analysis","collection","reconstruction","operator","write","credentials","unknown","internet","local","scope","ports","ufw",{"skillNo":154,"name":110,"nameZh":17,"description":111,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":54},"01M70P8QATMPKA78E4FT5D2TNA","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[115,116,117,130,131,132,126,129,122,119,44,120,121,123,124,125,118,49,127,128],{"skillNo":159,"name":135,"nameZh":17,"description":136,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":54},"01M70NMPVJ5H0JH131P60FW4R8","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fforensics-complete\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[140,141,152,151,144,150,149,128,143,145,44,146,125,142,49,147,116,132,131,148]]