agent-run-forensics – skill Agent & Tự động hóa cho agent AI
Dùng khi được hỏi vì sao agent làm một việc nào đó, phiên hoặc lần chạy trước đã thay đổi gì, test có thật sự pass không, hoặc cần kiểm chứng bản tóm tắt phiên. Trả lời dựa trên bản ghi transcript đã lưu, không dựa vào trí nhớ, với trace_finder.py, trace_timeline.py và claim_checker.py.
Cài skill agent-run-forensics bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/agent-run-forensics-6b491.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /agent-run-forensics – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/agent-run-forensics-6b491.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $agent-run-forensics – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/agent-run-forensics-6b491.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /agent-run-forensics – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/agent-run-forensics-6b491.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /agent-run-forensics – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Agent Run Forensics
> Portability: 3 stdlib Python CLIs and one hook. Read-only, no network, no model calls.
> Secrets in transcripts are redacted in every output, with no switch to turn that off.
Agents are confidently wrong about their own history. Asked "why did you change
config.yaml?", an agent answers from what it remembers, and memory drops the
parts that matter: the test run that failed, the file a sed -i one-liner
rewrote, the edit made after the last green run. The harness recorded all of it.
This skill makes the answer come from that recording.
The rule: when a question is about something that already happened, read the trace before answering.
Workflow
# 1 - Find the run (skip if the question is about this session: the hook gives you its path)
python scripts/trace_finder.py --since 7d --touched config.yaml
# 2 - Read it: what happened, in order, and which files changed
python scripts/trace_timeline.py --trace <path> --files # SILENT = changed, never named by the agent
python scripts/trace_timeline.py --trace <path> --grep timeout # or --errors, --file PATH, --around N
# 3 - Walk back from the step in question
python scripts/trace_timeline.py --trace <path> --why 9
# 4 - Before repeating any summary as fact, check it
python scripts/claim_checker.py --trace <path> --claim "passed:pytest" --claim "not-edited:config.yaml"Step 3 prints two lists and you keep them apart in the answer:
| Label | Means | Example |
|---|---|---|
| recorded | The harness wrote it down when it happened | the command, its exit code, the agent's words in the same message |
| inferred | Derived now by a named rule | prior-write, read-before-write, retry-after-failure, target-seen-in-output |
Say "the trace shows" only for recorded edges. Name an inferred edge as inferred, with its rule.
The agent's own stated reason is recorded as a *claim*, not as the cause.
Step 4 turns each sentence of a summary into a typed claim (ran:, not-run:,
passed:, failed:, edited:, not-edited:, read:). STALE means the tests
passed but files changed afterwards; PARTIAL means exit 0 came from the last
command of a pipe or ; chain. Exit 4 is a contradiction: correct the account first.
Hard rules
- No trace, no answer. If the finder returns nothing (exit 2), say the run is not recorded here. Do not reconstruct it.
- Cite steps. Every factual sentence about the run points at a step number.
- Recorded and inferred stay separate. Never merge them into one confident sentence.
- Shell effects are inferred unless the harness diff (
bashEditDiff) confirms them. A command's text says what it was meant to do, not what it did. - Exit 0 of a compound line is the last command's.
pytest | tee logpassing says nothing about pytest. - Quote no secrets. Outputs are redacted; do not paste raw transcript lines around the redaction.
Scripts
| Script | Role | Exit codes |
|---|---|---|
| scripts/trace_finder.py | Lists recorded sessions by repo, window, touched file, text | 0 found · 2 none · 3 bad input |
| scripts/trace_timeline.py | Numbered steps, --files table, --why STEP chain | 0 · 2 filter matched nothing · 3 |
| scripts/claim_checker.py | Typed claims vs the recording | 0 all supported · 2 weak · 3 · 4 contradicted |
All support --help, --sample and --output json. trace_core.py is the shared parser.
The plugin's UserPromptSubmit hook (hooks/forensics_hint.py) adds one line naming this
session's transcript when a prompt asks about past work; disable it with AGENT_RUN_FORENSICS_HOOK=0.
References and assets
- [
references/trace_sources.md](references/trace_sources.md): where each harness records, what is in a record, retention and limits (7) - [
references/recorded_vs_inferred.md](references/recorded_vs_inferred.md): why self-reports are not evidence, and the inference rules (7) - [
references/claim_verification.md](references/claim_verification.md): turning a summary into claims, verdicts, and how to correct an account (7) - [
assets/forensic_answer_template.md](assets/forensic_answer_template.md): the shape of an answer - [
assets/claims_example.txt](assets/claims_example.txt): a claims file for--claims-file
Skill liên quan
- agent-run-forensics – Dùng khi được hỏi vì sao agent làm một việc nào đó, phiên hoặc lần chạy trước đã thay…
- agent-workflow-designer – Thiết kế quy trình đa agent sẵn sàng cho production, chọn mô hình phù hợp (tuần tự, song…
- expert-prompt-migrator – Công cụ chuẩn hóa bất kỳ prompt chuyên gia/vai trò nào thành định dạng di động và chuyển…
- cors-chain-automation – Dùng khi cần phân loại CORS nhất quán cho một danh sách giới hạn các API endpoint đã…
- context-engineering – Tối ưu thiết lập ngữ cảnh cho agent. Dùng khi bắt đầu phiên mới, khi chất lượng đầu ra…
- agent-orchestration-multi-agent-optimize – Tối ưu hệ thống đa agent với profiling phối hợp, phân phối khối lượng công việc và điều…
- agent-orchestrator – Meta-skill điều phối tất cả agent trong hệ sinh thái. Tự động quét skill, ghép theo năng…
- agent-qa-authoring – Tạo, chỉnh sửa, kiểm tra và chạy test, suite và hook của Agent QA qua MCP hoặc CLI, đồng…