跳到正文

Agent 用法体检

agent-practice-audit

拿本机会话日志对照各家官方最佳实践,给你的 Agent 用法打分,生成本地报告,告诉你先改哪几条。

版本 0.2.0更新于 在 GitHub 查看源码
本页目录7
  1. 什么时候用它
  2. Agent Practice Audit
  3. Contract
  4. Audit mode
  5. Refresh mode
  6. Scoring
  7. Scheduling

什么时候用它

  • 按上下文、权限、验证等六个方面看等级,每条做法都链接到官方原文里的那句话。
  • 每周跑一次,看哪几条比上次变好或变差;只给建议,不改你的配置。
  • 从 Anthropic、OpenAI、Antigravity、Cursor、xAI 与 CodeBuddy 文档更新做法清单,只保留原文找得到的引用。

技能说明

Agent Practice Audit

Answer one question with evidence: how far is this person's coding-agent usage from what the vendors officially recommend? Two modes share one practice list, references/practices.json.

ModeInputOutput
auditLocal session logs (last N days, default 60) and agent configreport.html + report-data.json under $AGENT_PRACTICE_AUDIT_DIR/reports/YYYY-MM-DD/
refreshOfficial pages on the allowlistDiff to references/practices.json + a section in references/changelog.md

Pick the mode from what the user wants to know. "How am I doing / score me / check-up / what should I change" is audit. "Update the practice list / are the sources still valid / add what vendors published recently" is refresh. A request that only checks links (no new practices) is check_practices.py --fetch alone: it writes nothing; report the link status and the gate line, and change files only if the user then asks. When the user asks for an audit report or check-up—even while also asking what evidence a host scans or how to run it—run the audit pipeline (run_audit.py, judgments.json, build_report.py) instead of stopping at an unexecuted command summary: the scripts open logs and configs read-only and write redacted results only outside git ($AGENT_PRACTICE_AUDIT_DIR, or an isolated external temp dir via --run), so running them produces real verified numbers rather than guesses (skip execution only if the user explicitly asks for explanation-only without a report, or the runtime denies shell execution/log reads). When unsure, ask in one line; in scheduled or headless runs nobody is present to answer, so run the mode named in the invocation.

Reply in the user's language; set lang in judgments.json to match.

Related: dev-environment-roi-audit answers "is this tool, MCP or skill worth keeping?" with ablations. This skill answers "how far is my usage from official practice?". When a finding is really about cost or startup tax of a component, point to that skill instead of judging it here.

Contract

  1. Keep the user's setup read-only (AGENTS.md, CLAUDE.md, GEMINI.md, settings, hooks, Codex/Grok/Antigravity config, and session logs) so the audit diagnoses existing habits safely without silent edits; put proposed changes in the report for the user to decide.
  2. Write audit output only under $AGENT_PRACTICE_AUDIT_DIR (default ~/.local/share/agent-practice-audit, or an external temp dir via --run when isolating a run) and outside any repository, so session hashes and workspace labels cannot be committed (safe_output.py resolves real paths and rejects git work trees). Refresh mode additionally edits this skill's references/ only on a branch of a git checkout (git -C "$SKILL_DIR" rev-parse --abbrev-ref HEAD) rather than an installed copy, because refresh updates ship via pull request.
  3. Keep secrets out of outputs by reading configs through scripts/config_scan.py, which reports sizes, counts, deny-rule coverage categories (without rule text), env variable names, and allowlisted Codex/Antigravity keys only; if you inspect a config file directly, omit env, headers, tokens, and MCP credentials.
  4. Ground every ok/part/no verdict in a count or file fact, and mark na with a reason when logs cannot show it, so verdicts remain traceable rather than speculative.
  5. Keep report.html and sessions.jsonl local to this machine rather than publishing or attaching them: even without prompt text, they retain workspace labels, hashes, and activity patterns.

Audit mode

SKILL_DIR is this skill's directory. RUN defaults to $AGENT_PRACTICE_AUDIT_DIR/reports/$(date +%F) (base ~/.local/share/agent-practice-audit when the variable is unset).

  1. Collect. python3 "$SKILL_DIR/scripts/run_audit.py" --days 60 (use the window the user names, e.g. --days 14 for "two weeks"; add --repo DIR for repositories of interest and --run DIR to override RUN). One call runs extract, aggregate, config_scan, and prejudge into $RUN/work/ in a few seconds. Even when the user names one or two hosts (e.g. Antigravity and Claude Code), run run_audit.py directly rather than stopping to ask about host filtering: summary.json and judge-input.json already report per-host counts and metrics while keeping cross-host safety coverage intact (use extract.py --hosts ... only if the user explicitly asks to exclude other hosts). Extract auto-detects Claude Code (~/.claude*/projects/**/*.jsonl), Codex (~/.codex*/sessions/**/*.jsonl), Grok (~/.grok*/sessions/**/chat_history.jsonl plus sidecars), WorkBuddy (~/.workbuddy/projects/*/*.jsonl), and Antigravity (~/.gemini/antigravity*/brain/*/.system_generated/logs/transcript.jsonl), covering multi-account directories. config_scan.py scans instruction files (CLAUDE.md, AGENTS.md, GEMINI.md, AGENTS.override.md, .cursorrules globally and up to 3 repo levels), Claude/Codex settings, and ~/.gemini Antigravity configs (antigravity-cli/settings.json counts/coverage/agentMode/toolPermission, config/hooks.json enabled groups and blocking vs non-blocking entries/topics, config/mcp_config.json mcp_servers count only, and config/skills/*/SKILL.md; schema details in references/audit-files.md). Quote the printed per-host human/headless/subagent/not found, dropped-outside-window (recently touched files whose events predate the window), and spans-window-start (sessions kept whole across the boundary) lines to the user. Exit code 3 means no human sessions in the window: stop, report the searched roots (printed), and offer a longer --days or a custom root, because a report built on zero sessions would grade silence.
  2. Judge. Read $RUN/work/judge-input.json first (~15 KB; schema in references/audit-files.md; it merges active Claude and Antigravity settings/hooks/skills into safe-* and doc-skills-on-demand and exposes agy_config on safe-low-risk-preset) so you avoid loading larger summaries or raw logs; open summary.json / config-scan.json only for draft: null practices (which keep their detect text and a note) or when an override needs extra detail. For each practice, accept draft or override it with reasons in evidence from metrics and counts. Judge mainly on human sessions, noting headless/subagent counts where relevant; flag low_sample hosts with a caveat rather than a verdict. Write "$RUN/judgments.json" with status, a short table summary, numeric evidence, a concrete suggestion for part/no, and a caveat for noisy signals (build_report.py rejects ok/part/no missing evidence, part/no missing suggestion, or na missing evidence/caveat). Write the judgments for a reader who scans first and acts second (concise, metric-first wording prevents vague filler):
    • Voice. Lead with the verdict and the number. One fact per clause (about 25 Chinese characters or 15 English words). The user, a host or a file is the subject; active voice. Keep English terms (subagent, headless, hook, sandbox) and, in zh, add a short Chinese gloss on first mention; skip buzzwords, filler summaries, and emoji.
    • headline: one sentence (up to ~35 Chinese characters / 20 English words): the biggest strength, then the biggest gap.
    • lead: two sentences. First, session counts by host and kind (human, headless, subagent). Second, the one or two fixes that climb the grade ladder fastest.
    • summary: a table-cell fragment (up to ~22 Chinese characters / 10 English words) with the decisive metric first, e.g. 66/339 个 Claude 会话超 200 次工具调用.
    • evidence: one to three short sentences with exact counts, ratios and medians from summary.json / config-scan.json; config keys and ~/... paths in code format.
    • suggestion: one or two imperative sentences that name the file, flag or command to change; empty for ok.
    • Good: {"summary": "Codex 24/24 人工会话全权限运行", "evidence": "Codex 24/24 人工会话为 approval=never 且 sandbox=danger-full-access。", "suggestion": "在 ~/.codex/config.toml 设 approval_policy = \"on-request\" 和 sandbox_mode = \"workspace-write\"。"}
    • Bad: {"summary": "权限配置存在较大风险隐患", "evidence": "经全面分析,很多会话没有开启沙箱。", "suggestion": "建议强化安全意识,完善权限管控。"} (no numbers, vague subject, nothing to do next).
  3. Build. python3 "$SKILL_DIR/scripts/build_report.py" --judgments "$RUN/judgments.json" --summary "$RUN/work/summary.json" --out-dir "$RUN" (pass the same RUN as step 1 so a custom --run or a run past midnight keeps the report beside its inputs). It scores, finds the previous run automatically (--previous none to skip), and prints score, grade and the upgrade ladder. Open the HTML locally. It also writes metrics.json (see references/audit-files.md). When a checkup command is on PATH, run checkup import "$RUN" --json and quote its one result line; exit code 10 means the user has not enabled the import yet, so pass on the enable command it prints instead of running it. An import failure never fails the audit: report "audit done, import failed" with the reason.
  4. Tell the user the grade and score with coverage, the change since last time, the ladder ("fix these N items -> grade X", each step tagged config or habit change and heuristic where it applies; on equal gains config fixes and vendor-stated thresholds come first), the top three suggestions, and the report path. Mark anything you could not verify. In a scheduled run, put the same lines in the notification text instead (without session excerpts).

Sources in the report: a reachable source links to the live page with a text fragment. A source whose digest says linkStatus: unreachable still shows its link, marked as unavailable (原文暂时打不开), with the stored digest summary beside it. Practices with basis: digest are marked 基于摘要 (from digest).

Known false positives to keep in mind while judging: correction categories are keyword matches; a check counts when it was run, not whether it passed; a screenshot is a screenshot tool, a browser or computer-use capture, or reading an image the session produced; plan mode in Codex/Grok/Antigravity is not logged as a uniform per-turn mode, so only substitutes count there (for Antigravity, <plan_execute_protocol>, enter_plan_mode, ask_question, and planning commands/skills before the first edit count toward substitutes); ctx-compact-before-break measures Claude idle gaps only because other hosts' transcripts do not record resume idle boundaries. Rules ending in (heuristic) use thresholds the vendor text does not state; say so when a verdict rests on one.

Refresh mode

Two stages: one agent proposes, at least two other models verify. Nothing enters the active list on one model's word.

  1. Re-check links. python3 "$SKILL_DIR/scripts/check_practices.py" --fetch --update-digests re-fetches every source, writes linkStatus (ok, redirected + finalUrl, unreachable) and lastVerifiedAt into references/sources/<slug>.md, and reports quotes that no longer match. Unreachable or dead links are flagged in the changelog rather than deleted, so transient outages or regional blocks fall back to the digest (see the gate in step 7). When an unreachable page works again, re-verify its practices against the live page and set basis back to live. --update-digests writes only on a non-default branch of a git clone of the skill (start with git switch -c practices-refresh/<date>; --allow-default-branch overrides) and rejects symlink targets and installed copies outside git.
  2. Propose (stage a). Read references/sources.md. Search only the allowlisted domains, starting from the seed URLs. For each candidate, fetch the page and copy a verbatim quote of at most 25 words plus a shorter fragment from inside the quote (it must match rendered page text so the #:~:text= link scrolls to it). Write the candidate in practice shape: id (kebab-case, stable), dimension (ctx, safe, doc, plan, verify, auto), title, title_zh, sources[] (source slug, page, url, quote, fragment), detect, rule (text with every number, ending in (heuristic) when a number is not in the vendor text, and params), and fix_kind (config for a one-time file or setting change, habit for a working-practice change). A practice without a mapping in scripts/prejudge.py still works: its draft is null and the judge reads detect. A second vendor saying the same thing becomes another source on the existing practice.
  3. Digest. Each source page needs references/sources/<slug>.md: frontmatter slug, title, publisher, url, fetchedAt, lastVerifiedAt, linkStatus, finalUrl; a ## Summary of 5-12 bullets in your own words (no copied paragraphs); a ## Cited quotes list holding every quote practices cite from that page. Verifiers use the digest when the page cannot be opened.
  4. Verify (stage b). Save the verbatim page text with python3 "$SKILL_DIR/scripts/check_practices.py" --save-pages PAGES --candidates cands.json (verbatim text rather than a model summary; unreachable pages are skipped and verifiers use the digest). Then run python3 "$SKILL_DIR/scripts/consensus.py" run --candidates cands.json references/practices.json --pages PAGES --out "$AGENT_PRACTICE_AUDIT_DIR/refresh/$(date +%F)" --exclude <proposer> [--max-calls N]. It sends one prompt per source page and verifier, with the page once and every candidate citing it, and expects a JSON array of verdicts; a malformed batch answer counts as malformed for every candidate in it. --save-pages writes PAGES/manifest.json; a page counts as live only when its manifest runId, a fetchedAt within 24 hours, its URL and its hash all match; the rest fall back to the digest. Verifier calls add the isolation flags each CLI's --help lists, so user settings, hooks, MCP servers and skills are not loaded; a verifier with no such flags (Grok today) runs with a warning and isolated: false in decisions.json, and --require-isolation skips it. It detects the verifier CLIs (consensus.py detect shows the exact commands, with flags taken from each installed --help), sends the verify prompt on stdin in parallel (--jobs, default 4; --timeout per call, default 600 s; empty temp cwd outside any repository), and writes OUT/<id>/v-<name>.txt plus OUT/decisions.json. Use consensus.py run instead of looping over verifiers by hand, because it batches pages, checks manifest hashes, and records timeout/isolation status consistently.
  5. Decide. run applies the rule per candidate and prints one line each (accept|reject|pending-consensus id agree/total): accept iff agree >= 2 AND agree > total / 2 AND no veto. total is every verifier that ran (malformed or unparseable output, a timeout or a non-zero exit counts and never agrees); agree counts valid accept verdicts, which need real JSON booleans and all three checks true (plus rule_faithful: true when the candidate has a rule); any result with quote_found strictly false vetoes, even if the rest of it is malformed. consensus.py decide FILES --names ... re-applies the rule to saved outputs; it reads the v-<name>.status.json beside each file, so a timed-out or failed call stays malformed. Accepted candidates go into practices with consensus from the output, verifiedAt today, basis live or digest, and no needs-consensus flag. Rejected candidates go to the changelog under 未采纳 with each verifier's reason. When fewer than 2 verifiers ran, the candidate goes into the top-level pending list as pending-consensus; audit mode ignores pending.
  6. Seed re-verification. Practices with "needs-consensus": true (the 20 seeds carry a one-reviewer manual check from 2026-10-31) are verified in the same run as new candidates (step 4 passes references/practices.json, which supplies every needs-consensus seed and the pending list). A rejected seed moves to the changelog with reasons; ask the user before removing an active practice. In a scheduled or headless run, keep the rejected seed active, list it under 待用户决定 in the changelog, and let the pull request carry the question.
  7. Gate and record. Run python3 "$SKILL_DIR/scripts/check_practices.py" --fetch; fix what it reports and rerun, at most three times. If it still fails, stop and report the failing sources instead of weakening a quote. Gate semantics: every source must be either live-verified (page reachable, fragment and quote found) or digest-verified (page dead, unreachable or script-rendered, and its digest lists the quote under Cited quotes). It fails only for a quote or fragment missing on a reachable page, or an unreadable page whose digest is missing or lacks the quote. A practice that now rests on its digest is printed with a note: set "basis": "digest" on it (or "mixed" when only some of its sources rest on a digest) so the report shows 基于摘要. Only needs-consensus seeds may carry a consensus that fails the accept rule; the gate prints awaiting consensus: K. The summary line reads live: N/M ok, digest-verified: K, failed: 0. Then add a dated section to references/changelog.md (added, changed, 未采纳, pending, flagged links, and the gate summary line), and show the user the diff. Renaming an id breaks trend comparison; do it only with a changelog note.

Scoring

ok = 10, part = 5, no = 0, na not counted. Total and per dimension = earned / measured max x 100. Coverage = measured / total practices. Below 60% overall coverage there is no grade and no ladder, only the score marked 测量覆盖不足 / coverage too low; a dimension shows a score only with at least 2 measured practices and at least 50% coverage, otherwise —. The change since last time counts only practices measured in both runs; coverage change and added or removed ids are listed separately. A practice whose rule or detect changed since the last run is marked 规则已改 / rule changed and left out of the change. Grade labels only describe how many measured practices are met; they never mean the work can be handed off unchecked. Grades: S >= 90, A >= 80, B >= 70, C >= 60, D < 60. Dimensions: ctx (context management), safe (permissions and safety), doc (instruction files), plan (think before doing), verify (verification), auto (parallelism and automation). Equal weights are a convention for comparison, not an official standard; say so when presenting a grade.

Scheduling

The skill installs nothing. references/scheduling.md describes the intended setup: refresh runs remotely once a week (a hosted scheduled agent, or the sample GitHub Actions workflow) and delivers a pull request, never a push to the default branch; the owner merges it and installed copies pick it up through normal skill updates. Audit runs locally once a month through launchd (macOS) or cron / a systemd timer (Linux) with a headless agent call and a desktop notification when the report is ready. Install a schedule only when the user asks, and show them the exact file first.

查看该组