Skip to content

[docs] - Align the loop and persona skills with the commit hook and verification policy - #1642

Merged
cgfixit merged 3 commits into
mainfrom
claude/skills-loop-conventions
Oct 13, 2026
Merged

cgfixit merged 3 commits into
mainfrom
claude/skills-loop-conventions

Conversation

@cgfixit

@cgfixit cgfixit commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Proposed changes

Skill-catalog resync, part 1 of 3 (parts 2 and 3, #1643 and #1645, are merged; all three touch disjoint files). This PR reconciles the four *-refactor loops, add-comment, karpathy-guidelines, verification-specialist, CyClaw-Optimize and babysit-github-pr with what the repo enforces today.

Every SKILL.md was read end to end and each concrete claim checked against the code, config.yaml, the hooks and the workflows. What changed:

  • Commit subjects the hook refuses. The loops told agents to commit as refactor:, perf:, test(fix):, log(coverage):, docs(retrieval): and ci:. The tracked .githooks/commit-msg accepts only [prefix] - Short descriptive sentence. Each skill now shows the hook-compliant form once and says why.
  • Verification policy (CLAUDE.md §5, owner decision 2026-10-08). Routine full-suite / --cov runs are replaced by the §5 order: run the changed code, lint, let GitHub Actions run the suites, one targeted test file at most. tests-refactor and logging-refactor keep their whole-suite measurement loop but state that an explicit /tests-refactor is the owner's authorization. Their metric extraction is fixed (grep -E "\d" matches nothing in GNU grep; the doubled -q on top of pyproject's addopts becomes -qq and hides the N passed line).
  • Stale references. "Feature freeze (CLAUDE.md §1)" in three skills (no such section exists); CLAUDE.md §4 cited for rules that live in §5/§6; the fictional conftest checklist in tests-refactor (utils.rate_limit, RateLimiter._store, a session fixture that builds a real index); RateLimiter.check() (the method is allow()); logging.getLogger(__name__) + extra={} presented as the house pattern (CLAUDE.md §5 says cyclaw.<module> + lazy %s); hash(query) as a query identifier (the repo uses the keyed HMAC query_fingerprint); the harness/ sweep target removed by [infra] - Remove the Python coding-harness console; CG-agent-harness owns that role #1367; agent/ as the branch prefix for Claude Code; the two-header description of pr-template-check.yml (it now requires all eight sections, the stamp line and the title format).
  • speed-refactor no longer times a 401 on /soul, no longer profiles by running gate.py's __main__, and states that the 50 ms gate cannot apply to a live 27B generation path. The hand-run uvicorn gate:app --host … --no-proxy-headers recipe that tests/test_gate.py::TestProxyHeaderTrust pins stays (the first push dropped it and failed the ci (3.12) and ubuntu-22.04 legs; 019bce7 restored it).
  • babysit-github-pr now says what its scripts actually do (snapshot, wait, classify by log text) versus what the agent does by hand, that ALLOW_FORCE_WITH_LEASE is the operator's hook override and never set by an agent, that a human merges in this repo, and records the two helper-script gaps found (gh pr checks --json name,status is rejected by current gh; --repo . is not a valid repo). Those script fixes are left for a follow-up because gh pr checks cannot be exercised from this sandbox (GraphQL is blocked).
  • Two thin command wrappers updated to match (architecture-refactor.md no longer names a nonexistent "autoreview" tool; verification-specialist.md no longer calls the full suite "the lighter-weight check").
  • Trim pass (3646a2a, at the owner's request): the four loops' identical tracker-init heredocs and decision trees are one-liners; the fictional tracker/report examples are gone; verification-specialist lists CyClaw's own surfaces instead of Mobile/DB-migration/terraform strategies; CyClaw-Optimize, babysit and add-comment lose sections that restated Step 3.5, CLAUDE.md §3/§4 or an earlier step of the same file.

Net: 416 insertions, 622 deletions across 12 files.

Invariant / Governance Impact: none of the six invariants or I6 is touched; no code outside .claude/ changes. The agent instruction surface (.claude/skills, .claude/commands) is what changed, which the pre-commit security gate flagged as a reminder; every edit is reproduced in the diff for line-by-line review.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Security (auth, privacy, injection, egress, redaction, or secrets)
  • Invariant / Governance refinement (use this for changes that strengthen or evolve the 6 invariants, I6 isolation, or harness phases)
  • Dependencies (added, removed, or bumped)
  • CI / infrastructure (workflows, hooks, templates, or checkers)
  • Refactor or tests (behavior-preserving, no new capability)
  • Documentation update
  • Other (none of the boxes above fit)

Scope note: Docs + audits (agent skill files only).

Benefits / why

  • An agent following these skills as written would be refused by the commit hook on its first commit and would burn minutes on full-suite runs the owner has said belong to CI.
  • Stale facts in instruction files propagate: the tests-refactor conftest checklist alone described three fixtures that have never existed.
  • Shorter, truer skill files cost fewer tokens per load and mislead fewer sessions.

Risks to monitor

  • A skill now points at driver.sh serve/probe for live checks; if cyclaw-gotchas/driver.sh changes its subcommands, three skills drift together (doc-sync does not parse skill prose).
  • babysit-github-pr's script gaps are documented, not fixed; the scripts remain scaffolding until a follow-up corrects the gh calls.
  • The tests-refactor/logging-refactor exemption from §5 rests on "user-invoked only"; if either ever loses disable-model-invocation: true, the exemption text must go with it.

Checklist

  • I have read docs/THREAT_MODEL.md, INVARIANTS.md and SECURITY.md (and any relevant Phase docs)
  • This change preserves all 6 security invariants and I6 module isolation (no code touched)
  • Full sandbox validation has been run — not run locally; per CLAUDE.md §5 the suites ran in GitHub Actions and every leg is green on 3646a2a. Run directly: doc_sync.py (0 drift), babysit-github-pr/verify.sh (pass), bash -n on the edited bootstrap script, the new metric/median shell snippets and the tracker one-liner executed against sample input, and the test_gate recipe rule replicated against both skill files.
  • No new external network dependencies or mandatory online LLM assumptions were introduced
  • For any agentic/fsconnect change — n/a
  • Relevant architecture docs or threat model notes have been updated if core behavior or topology changed — n/a, none changed
  • Commit messages follow the title prefix convention above
  • For large or complex changes: before/after invariant matrix — n/a

Further comments

Verification against the repo was done by five read-only subagents (one per skill group), each finding re-checked by hand before editing. Findings that were out of scope for a docs PR and are not addressed here: the run-babysit.sh/pr-state.sh/wait-for-checks.sh gh invocation bugs; tests-refactor's 100% coverage aspiration (left as the loop's stated goal, with the real fail_under = 80 gate named beside it).

Suggested merge order of open PRs

Trial merge verified (git merge --no-commit --no-ff + abort) against main @ 6902d39 on 2026-10-13 (after #1637, #1638, #1640, #1643 and #1645 merged). This PR touches only loop/persona skill files under .claude/ and overlaps none of the other open PRs.

#1641 · Safe ✅
Impact: CI bwrap/AppArmor workflow; independent.
Action: merge anytime.

#1642 (this PR) · Safe ✅
Impact: independent; loop/persona skill files only.
Action: merge anytime; re-run the trial merge if main moves.

#1644 · Safe ✅
Impact: CI bwrap/AppArmor selection; independent of this PR.
Action: merge anytime.

#1646 · Safe ✅
Impact: otel-hardening inventory; independent of this PR.
Action: merge anytime.

ELI5

The repo's "how to work here" cheat-sheets for the refactor loops and a few helper personas had gone out of date: they told an agent to write commit messages the repo's own gatekeeper script rejects, to run the whole 5,000-test suite after every small step even though the owner decided the CI robots should do that, and to look for fixtures and files that don't exist. This PR rewrites those sentences to match what the repo actually enforces today, deletes the made-up bits, and then trims the four loop sheets' copy-pasted setup boilerplate to one line each. Nothing in the running server changes. What could still go wrong: the sheets now point at the driver.sh helper for live checks, so if that helper is renamed, these files go stale again; the signal is doc-sync staying green while a skill quietly names a command that no longer exists, so keep the manual pass in the loop.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LbrgG4NUbR3sUTgNMfKXpU


Generated by Claude Code

Last updated: 2026-10-13 05:56 ET

…erification policy

The four *-refactor loops, add-comment, karpathy-guidelines, CyClaw-Optimize
and babysit-github-pr told agents to commit with `refactor:`/`perf:`/
`test(fix):`/`log(...)`/`docs(...)`/`ci:` subjects, all of which the tracked
commit-msg hook refuses, and to run the full `pytest tests/` (or `--cov`)
suite as a routine step, which CLAUDE.md §5 reserves for CI and the owner.
Both are now stated once per skill, with the hook-compliant subject form and
the §5 verification order (run the code, lint, let Actions run the suites,
one targeted file at most). tests-refactor and logging-refactor keep their
whole-suite measurement loop but say plainly that an explicit invocation is
the owner's authorization.

Also removed or corrected: the "feature freeze (CLAUDE.md §1)" references
(no such section), the fictional conftest fixture checklist
(`utils.rate_limit`, `RateLimiter._store`, a real-index session fixture),
`grep -E "\d"` metric extraction (GNU grep has no \d) and the doubled `-q`
that hides pytest's summary line, the unauthenticated `/soul` timing in
speed-refactor, the retired `harness/` sweep target and the old two-header
template-check description in CyClaw-Optimize, the `agent/` branch prefix
where `claude/` is the documented one, and the babysit claims that its
scripts fix comments, query run history, or prompt for a test command.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LbrgG4NUbR3sUTgNMfKXpU
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR is a complete fill of .github/PULL_REQUEST_TEMPLATE.md (every section, ticked boxes, merge order, ELI5 last, last-updated stamp, title, branch).

…d-refactor

tests/test_gate.py::TestProxyHeaderTrust requires every copy-paste start
recipe in the skill docs to name uvicorn gate:app --host with
--no-proxy-headers; the driver.sh serve replacement dropped that line and
failed the ci (3.12) and ubuntu-22.04 legs on 855fee4.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LbrgG4NUbR3sUTgNMfKXpU
…c strategies and restated rules

Collapses the four refactor loops' identical tracker-init heredocs and
decision trees into one-liners, drops the fictional tracker and report
examples, removes the Mobile/DB-migration/terraform strategies from
verification-specialist in favour of CyClaw's own surfaces, and cuts the
CyClaw-Optimize, babysit and add-comment sections that restated Step 3.5,
CLAUDE.md §3/§4 or an earlier step of the same file. 59 insertions, 248
deletions; no guidance removed that is not stated once elsewhere in the file
or in CLAUDE.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LbrgG4NUbR3sUTgNMfKXpU
@cgfixit
cgfixit marked this pull request as ready for review October 13, 2026 10:09
@cgfixit
cgfixit merged commit af5871e into main Oct 13, 2026
60 of 61 checks passed
@cgfixit
cgfixit deleted the claude/skills-loop-conventions branch October 13, 2026 10:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T10:18:27.450952Z 3646a2a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3646a2ad2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +101 to +102
GROK_API_KEY=dummy python3 -m cProfile -s cumulative -c \
"from fastapi.testclient import TestClient; import gate; TestClient(gate.app).get('/health')" 2>&1 | head -40

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace the unsupported cProfile invocation

When the speed-refactor loop reaches per-request profiling, this command exits before importing gate: python3 -m cProfile --help accepts [-m module | scriptfile], and executing the documented command on Python 3.12 returns exit 2 with no such option: -c. Use a temporary script, cProfile.runctx, or another supported invocation so the prescribed profiling step can actually run.

Useful? React with 👍 / 👎.

Comment on lines +214 to +218
new session-scoped ones: `client` (a function-scoped `TestClient` over the
mocked gateway, one loopback IP per test file so rate-limit state cannot
leak), `test_config` (a deepcopy — `test_conftest_fixtures` guards that), and
the autouse mocks for the embedder, Ollama, Grok and Claude. Nothing builds a
real index and nothing starts a live service (CLAUDE.md §6 "Test").

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the pytest fixture isolation guidance

When an agent adds another test file following this guidance, client does not allocate one peer per file: tests/conftest.py:517-526 defaults every direct use to ("127.0.0.1", 51234), and its own docstring requires consumers to choose distinct peers because the rate limiter is process-global. The service patches are also scoped to _mocked_gateway/client, not autouse mocks. Promising this isolation can therefore create order-dependent 429s or tests that unexpectedly reach real dependencies; document the required peer parametrization and explicit mocks instead.

Useful? React with 👍 / 👎.

Comment on lines +53 to +57
Follow CLAUDE.md §5's verification order: run the code you moved (import the
new module, call the extracted function, or hit the endpoint with
`driver.sh serve` + `probe`), then lint, and let GitHub Actions run the full
suite on the pushed draft PR. When a step cannot be exercised that way, run the
one test file that covers it:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add the missing publish step before waiting for CI

On an architecture-refactor run with only local commits, this workflow has no push or draft-PR creation step: after verification it commits and loops back to assessment. It nevertheless defers the suite to Actions here and later requires green CI on the pushed head before stopping, so the loop cannot satisfy its own completion condition. Add an explicit push/draft/CI phase, or defer the CI criterion until a separate publication phase.

AGENTS.md reference: AGENTS.md:L49-L49

Useful? React with 👍 / 👎.

# Find except blocks with no logging
grep -n "except" **/*.py | grep -v "log\|logger\|print\|LOG"
# Find except blocks with no logging (rg recurses; bash's ** needs globstar)
rg -n "^\s*except\b" --type py -A2 . | rg -v "log|logger|LOG|raise"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the exception scan block-aware

When the logging audit runs this pipeline, the second rg filters individual output lines rather than whole exception blocks: every except line survives because it lacks log, while a following logger.* line is merely removed. For example, the already-logged handler at gate.py:464-465 is still reported, so this scan identifies most exception handlers as gaps and can prompt duplicate logging. Group each context block before testing it for logging, or use a small AST-aware script.

Useful? React with 👍 / 👎.

- **Data / ML:** Run a sample input through the pipeline. Verify output shape, schema, and value ranges. Test with empty inputs, null values, NaN, and confirm row or record counts.
- **Database migrations:** Run the migration up. Verify the resulting schema matches expectations. Run the migration down. Test against existing seed or fixture data.
- **Refactoring:** The existing test suite must pass without modification. Diff the public API surface to confirm nothing was unintentionally changed. Spot-check key behaviors end-to-end.
- **Backend / API (gate.py, the route modules):** Start the server (`driver.sh serve`). Curl each relevant endpoint. Inspect response status codes, headers, and body shapes. Deliberately send bad input to exercise error-handling paths.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep live verification writes out of the checkout

For a backend verification task, driver.sh serve conflicts with this skill's strict prohibition on modifying project files: cmd_serve runs mkdir -p logs, starts gate.py with the repository config, and the subsequent probe can write application and audit logs in the checkout. Use disposable sink/personality/index paths or an isolated checkout before prescribing this live flow.

AGENTS.md reference: AGENTS.md:L49-L49

Useful? React with 👍 / 👎.

| Pass rate | 62% | 100% |
| Coverage | 41% | 100% |
| Tests total | 18 | 47 |
| Pass rate | 98.1% | 100% |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the final coverage example consistent with the exit gate

When this loop reaches its stated stopping condition, coverage must equal 100%, but the newly updated Final State example records only 91% while presenting the run as completed. That contradictory template can lead an agent to stop and report success before the loop's mandatory target is met; either retain 100% as the final example or label sub-100% output as an incomplete/exhausted run.

Useful? React with 👍 / 👎.

Comment on lines +39 to +42
`--cov=.`, and keep `-o addopts=""` so the doubled `-q` does not hide the
summary line (see `tests-refactor`'s Measurement Protocol for both). Extract
the metrics with the same Python snippet `tests-refactor` uses; GNU `grep -E`
does not understand `\d`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore a self-contained logging metrics command

When /logging-refactor reaches its required measurement step, this section no longer contains any command that extracts PASSED, FAILED, ERRORS, PASS_RATE, or COVERAGE; it only tells the agent to find a Python snippet in another skill. That makes this loop non-standalone and leaves its decision tree without the metrics it requires if the other skill is unavailable or changes. Keep the corrected extraction snippet here, or move it into a shared executable both skills invoke.

Useful? React with 👍 / 👎.

4. Run linters and type-checkers if the project has them configured.
5. Check for regressions in areas adjacent to the change.

In CyClaw specifically (CLAUDE.md §5 and §8): there is no build step; "the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve package-build verification

For packaging or manifest changes, this CyClaw-specific override causes the specialist to skip a real build even though the project has one: .github/workflows/ci.yml:341 runs python -m build --wheel, and .github/workflows/python-publish.yml:55 runs python -m build. This contradicts the universal build check immediately above and can miss broken wheel metadata or package contents; remove the blanket “no build step” exception or scope it only to changes that cannot affect packaging.

AGENTS.md reference: AGENTS.md:L7-L7

Useful? React with 👍 / 👎.

Comment on lines +163 to 165
ruff check --select E,F,I,B,C4,UP,S --ignore E501 <touched files>
python3 -c "import <touched.module>" # a stray quote breaks here, not in CI
python3 .claude/skills/invariant-guard/check_invariants.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use file-type-aware syntax checks for comment changes

When this skill comments a permitted non-Python target such as config.yaml, a shell launcher, PowerShell file, or frontend asset, import <touched.module> is not a runnable verification command and cannot detect malformed syntax in that file. Even for Python scripts that are not importable modules, the prescribed check fails for the wrong reason. Select validation by file type—such as py_compile, YAML parsing, bash -n, or the appropriate frontend checker—instead of requiring every touched file to be importable.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants