tmux-video-evidence
Record captioned terminal evidence videos with portable, sanitized outputs for authorized review
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 6
- Forks
- 0
01 前言 Front Matter
- name
- tmux-video-evidence
- description
- Record captioned terminal evidence videos with portable, sanitized outputs for authorized review
02 资源文件 1
- 资产文件assets/browser-check.md460 B
03 SKILL.md 正文
Tmux Video Evidence for Agent Work Verification
Purpose
Prove terminal execution against a specific commit and publish reviewable evidence that both humans and agents can consume directly from the PR.
Required Outputs
Every terminal evidence package must include:
- A terminal video (
.mp4preferred) - A browser-friendly preview artifact (
.gifrecommended) - Captions for that video (burned-in preferred;
.vtt/.srtacceptable) - Sanitized terminal/test output (no machine-specific absolute paths)
- Media links accessible to the intended reviewer at an authorized destination
- A downloadable high-fidelity artifact (
.mp4or.mp4.zip)
Mandatory Video Sections
Record these sections in order:
| # | Section | Must show |
|---|---|---|
| 1 | Git Provenance | git rev-parse HEAD, branch, merge-base |
| 2 | Commit Log | git log --oneline origin/main..HEAD |
| 3 | Code Diffs | git diff origin/main...HEAD (not just --stat) |
| 4 | PR Status | gh pr view <N> |
| 5 | Live Work | Real test/deploy/command output |
| 6 | Post-run SHA | Same git rev-parse HEAD as section 1 |
Evidence Script Template
This template contains placeholders. Do not execute it directly or invent fallback defaults. Before creating /tmp/${WORK_NAME:-work}_evidence.sh (or resolving in scratch directory via ~/.claude/skills/scratch-space/SKILL.md: SCRATCH_TMP="$(~/.claude/skills/scratch-space/scripts/scratch-dir.sh tmp)"), complete all placeholder fields with the user's actual PR number, scoped test command, and relevant modified files:
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
cd "$REPO_ROOT"
echo "=== 1. PRE-RUN SHA ==="
HEAD_SHA="$(git rev-parse HEAD)"
echo "$HEAD_SHA"
git branch --show-current
git merge-base HEAD origin/main
echo "=== 2. COMMIT LOG ==="
git log --oneline origin/main..HEAD
echo "=== 3. CODE DIFFS ==="
git diff origin/main...HEAD -- <path/to/important_file_1.py> | sed -n '1,80p'
git diff origin/main...HEAD -- <path/to/important_file_2.py> | sed -n '1,80p'
echo "=== 4. PR STATUS ==="
gh pr view "<PR_NUMBER>" --json number,title,url,state,headRefName
echo "=== 5. LIVE TEST EXECUTION (SANITIZED) ==="
<SCOPED_TEST_COMMAND> 2>&1 \
| sed -E \
-e 's#/Users/[^/]+/#/<redacted-home>/#g' \
-e 's#/home/[^/]+/#/<redacted-home>/#g' \
-e 's#/private/var/folders/[^[:space:]]+#/private/var/folders/REDACTED#g' \
-e 's#/workspace/[^[:space:]]+#/workspace/REDACTED#g' \
-e 's#/tmp/[^[:space:]]+#/tmp/REDACTED#g'
echo "=== 6. POST-RUN SHA ==="
POST_SHA="$(git rev-parse HEAD)"
echo "PRE=$HEAD_SHA"
echo "POST=$POST_SHA"
[ "$HEAD_SHA" = "$POST_SHA" ] && echo "SHA MATCH"
Recording
# Resolve scratch directory via ~/.claude/skills/scratch-space/SKILL.md
SCRATCH_TMP="$(~/.claude/skills/scratch-space/scripts/scratch-dir.sh tmp)"
if [ "$?" -ne 0 ]; then
echo "Scratch resolver unavailable; refusing recording" >&2
exit 75
fi
if [ -z "$SCRATCH_TMP" ]; then
echo "Scratch resolver returned an empty path; refusing recording" >&2
exit 75
fi
chmod +x "${SCRATCH_TMP}/${WORK_NAME:-work}_evidence.sh"
# Option A: direct screen recording (mp4)
# (Use Kap or equivalent and run "${SCRATCH_TMP}/${WORK_NAME:-work}_evidence.sh" in the visible terminal)
# Option B: asciinema capture, then convert to mp4
timeout 120 asciinema rec "${SCRATCH_TMP}/${WORK_NAME:-work}.cast" --command "${SCRATCH_TMP}/${WORK_NAME:-work}_evidence.sh" --idle-time-limit 5 --overwrite
agg --cols 120 --rows 50 "${SCRATCH_TMP}/${WORK_NAME:-work}.cast" "${SCRATCH_TMP}/${WORK_NAME:-work}.gif"
ffmpeg -y -i "${SCRATCH_TMP}/${WORK_NAME:-work}.gif" -movflags +faststart -pix_fmt yuv420p "${SCRATCH_TMP}/${WORK_NAME:-work}.mp4"
Captions (MANDATORY)
For every tmux video, provide captions by either:
- Burning captions into the video (preferred), or
- Producing
${SCRATCH_TMP}/<work_name>.vttor.srt(resolved via~/.claude/skills/scratch-space/scripts/scratch-dir.sh tmp) and linking that actual file alongside the reviewed media artifacts.
Use ~/.claude/skills/video-caption/SKILL.md when you need to generate burned-in captions reliably.
Evidence access and authorized publication
Follow ~/.claude/skills/evidence-standards/SKILL.md for publication authority, audience, and destination. A PR, checked-in document, access-controlled receipt/store, or authorized gist may link the evidence. A gist or GitHub upload is not an independent acceptance requirement. Preserve real media, captions, exact source provenance, and reviewer access; publish only within the current authorization.
The following GitHub release example applies only when that destination is authorized. Verify the intended PR exists via gh pr view before creating any release or upload. Caller must provide non-empty VIDEO_FILE and PREVIEW_FILE artifacts, an explicit non-empty RUN_ID, an explicit non-empty CAPTURED_SHA matching the PR head SHA, and declare an explicit caption choice: set CAPTION_FILE to the actual .vtt or .srt sidecar path, or set CAPTION_MODE=burned when captions are burned into the video. All media and subtitle formats are verified with ffprobe prior to archive creation and publication. Packaging creates a new archive in a private temporary directory so existing user archives are never overwritten or updated with stale entries. Each run publishes to an immutable unique release tag combining the PR number, commit SHA, and run identifier without overwriting or clobbering existing releases.
(
set -euo pipefail
repo="${REPO:-}"
url_regex='^https://github\.com/([^/]+/[^/]+)/pull/([1-9][0-9]*)/?$'
if [[ -n "${PR_NUMBER_OR_URL:-}" ]]; then
if [[ "$PR_NUMBER_OR_URL" =~ $url_regex ]]; then
url_repo="${BASH_REMATCH[1]}"
url_pr="${BASH_REMATCH[2]}"
if [[ -n "$repo" && "$repo" != "$url_repo" ]]; then
echo "Error: Conflicting repository target '$repo' vs PR URL '$url_repo'" >&2
exit 1
fi
repo="${repo:-$url_repo}"
if [[ -n "${PR_NUMBER:-}" && "${PR_NUMBER}" != "$url_pr" ]]; then
echo "Error: Conflicting PR number '${PR_NUMBER}' vs PR URL '$url_pr'" >&2
exit 1
fi
PR_NUMBER="$url_pr"
elif [[ "$PR_NUMBER_OR_URL" =~ ^[1-9][0-9]*$ ]]; then
if [[ -n "${PR_NUMBER:-}" && "${PR_NUMBER}" != "$PR_NUMBER_OR_URL" ]]; then
echo "Error: Conflicting PR number '${PR_NUMBER}' vs PR_NUMBER_OR_URL '$PR_NUMBER_OR_URL'" >&2
exit 1
fi
PR_NUMBER="${PR_NUMBER:-$PR_NUMBER_OR_URL}"
else
echo "Error: PR_NUMBER_OR_URL must be a valid GitHub PR URL or positive PR number" >&2
exit 1
fi
fi
if [[ -n "${PR_NUMBER:-}" && "$PR_NUMBER" =~ $url_regex ]]; then
url_repo="${BASH_REMATCH[1]}"
url_pr="${BASH_REMATCH[2]}"
if [[ -n "$repo" && "$repo" != "$url_repo" ]]; then
echo "Error: Conflicting repository target '$repo' vs PR URL '$url_repo'" >&2
exit 1
fi
repo="${repo:-$url_repo}"
PR_NUMBER="$url_pr"
fi
if ! command -v ffprobe >/dev/null 2>&1; then
echo "Error: ffprobe is required for media validation but not found in PATH" >&2
exit 1
fi
if [[ -z "${PR_NUMBER:-}" || "$PR_NUMBER" == *"<"* || ! "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
echo "Error: PR_NUMBER must be set to a valid PR number before publication" >&2
exit 1
fi
if [[ -z "${repo:-}" || "$repo" == *"<"* ]]; then
echo "Error: REPO must be set to a valid owner/repo before publication" >&2
exit 1
fi
if [[ ! "$repo" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]]; then
echo "Error: REPO must be in the format 'owner/repo'" >&2
exit 1
fi
if [[ -z "${RUN_ID:-}" || "$RUN_ID" == *"<"* ]]; then
echo "Error: RUN_ID must be set to an explicit nonempty identifier before publication" >&2
exit 1
fi
if [[ -z "${CAPTURED_SHA:-}" || "$CAPTURED_SHA" == *"<"* ]]; then
echo "Error: CAPTURED_SHA must be set to the explicit commit SHA captured in the evidence" >&2
exit 1
fi
if [[ -z "${VIDEO_FILE:-}" || "$VIDEO_FILE" == *"<"* ]]; then
echo "Error: VIDEO_FILE must be set to a valid path before publication" >&2
exit 1
fi
if [[ -z "${PREVIEW_FILE:-}" || "$PREVIEW_FILE" == *"<"* ]]; then
echo "Error: PREVIEW_FILE must be set to a valid path before publication" >&2
exit 1
fi
video_file="$VIDEO_FILE"
preview_file="$PREVIEW_FILE"
if [ ! -f "$video_file" ] || [ ! -s "$video_file" ]; then
echo "Error: Video file '$video_file' not found or is empty" >&2
exit 1
fi
if [ ! -f "$preview_file" ] || [ ! -s "$preview_file" ]; then
echo "Error: Preview file '$preview_file' not found or is empty" >&2
exit 1
fi
video_codec="$(ffprobe -v error -select_streams v:0 -show_entries stream=codec_type -of default=noprint_wrappers=1:nokey=1 "$video_file" 2>/dev/null || true)"
if [[ "$video_codec" != "video" ]]; then
echo "Error: Video file '$video_file' does not contain a valid video stream" >&2
exit 1
fi
preview_codec="$(ffprobe -v error -select_streams v:0 -show_entries stream=codec_type -of default=noprint_wrappers=1:nokey=1 "$preview_file" 2>/dev/null || true)"
if [[ "$preview_codec" != "video" ]]; then
echo "Error: Preview file '$preview_file' does not contain a valid video/image stream" >&2
exit 1
fi
if [[ -n "${CAPTION_MODE:-}" && "${CAPTION_MODE:-}" != "burned" ]]; then
echo "Error: Unsupported CAPTION_MODE '${CAPTION_MODE}': only CAPTION_MODE=burned is supported" >&2
exit 1
fi
if [[ -n "${CAPTION_FILE:-}" && "${CAPTION_MODE:-}" == "burned" ]]; then
echo "Error: Cannot specify both CAPTION_FILE and CAPTION_MODE=burned: choose exactly one caption option" >&2
exit 1
fi
if [[ "${CAPTION_MODE:-}" == "burned" ]]; then
caption_file=""
elif [[ -n "${CAPTION_FILE:-}" && "${CAPTION_FILE:-}" != *"<"* ]]; then
caption_file="$CAPTION_FILE"
if [ ! -f "$caption_file" ] || [ ! -s "$caption_file" ]; then
echo "Error: Caption sidecar '$caption_file' specified but not found or is empty" >&2
exit 1
fi
caption_codec="$(ffprobe -v error -show_entries stream=codec_type -of default=noprint_wrappers=1:nokey=1 "$caption_file" 2>/dev/null || true)"
if [[ "$caption_codec" != "subtitle" ]]; then
echo "Error: Caption file '$caption_file' does not contain a valid subtitle stream" >&2
exit 1
fi
else
echo "Error: Explicit caption choice required: specify CAPTION_FILE (.vtt/.srt) or CAPTION_MODE=burned" >&2
exit 1
fi
# Verify exact intended PR before any release creation or mutation
pr_view_json="$(gh pr view "$PR_NUMBER" --repo "$repo" --json number,headRefOid,url)"
pr_head_sha="$(printf '%s' "$pr_view_json" | jq -r '.headRefOid // empty')"
pr_number_resolved="$(printf '%s' "$pr_view_json" | jq -r '.number // empty')"
if [[ -n "$pr_number_resolved" && "$pr_number_resolved" != "$PR_NUMBER" ]]; then
echo "Error: Verified PR number mismatch ($pr_number_resolved vs $PR_NUMBER)" >&2
exit 1
fi
if [[ -z "$pr_head_sha" ]]; then
echo "Error: Unable to resolve head SHA for PR #$PR_NUMBER in $repo" >&2
exit 1
fi
if [[ "$CAPTURED_SHA" != "$pr_head_sha" ]]; then
echo "Error: Declared CAPTURED_SHA '$CAPTURED_SHA' does not match verified PR head '$pr_head_sha'" >&2
exit 1
fi
sha_short="${CAPTURED_SHA:0:12}"
tag="evidence-pr-${PR_NUMBER}-${sha_short}-${RUN_ID}"
archive_scratch="$("${CLAUDE_HOME:-$HOME/.claude}/skills/scratch-space/scripts/scratch-dir.sh" tmp)" || {
echo "Scratch resolver unavailable; refusing archive allocation" >&2
exit 75
}
[[ -n "$archive_scratch" ]] || {
echo "Scratch resolver returned an empty path; refusing archive allocation" >&2
exit 75
}
archive_dir="$(mktemp -d "$archive_scratch/evidence_archive.XXXXXX")" || {
echo "Scratch archive allocation failed" >&2
exit 75
}
zip_file="$archive_dir/$(basename "$video_file").zip"
trap 'rm -f -- "$zip_file"; rmdir -- "$archive_dir"' EXIT
zip -j "$zip_file" "$video_file"
assets=("$zip_file" "$preview_file")
if [ -n "$caption_file" ]; then
assets+=("$caption_file")
fi
if ! gh release create "$tag" --repo "$repo" --target "$CAPTURED_SHA" --draft --title "PR #${PR_NUMBER} Evidence" --notes ""; then
echo "Error: Release '$tag' could not be created or already exists; stopping without modifying releases" >&2
exit 1
fi
release_json="$(gh release view "$tag" --repo "$repo" --json assets,targetCommitish,url)"
release_target="$(printf '%s' "$release_json" | jq -r '.targetCommitish // empty')"
if [[ -z "$release_target" || ! "$release_target" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "Error: Unable to resolve valid target commit for release '$tag' in $repo" >&2
exit 1
fi
if [[ "$release_target" != "$CAPTURED_SHA" ]]; then
echo "Error: Verified release target commit '$release_target' does not match CAPTURED_SHA '$CAPTURED_SHA'" >&2
exit 1
fi
gh release upload "$tag" --repo "$repo" "${assets[@]}"
release_json="$(gh release view "$tag" --repo "$repo" --json assets,targetCommitish,url)"
release_target="$(printf '%s' "$release_json" | jq -r '.targetCommitish // empty')"
if [[ -z "$release_target" || ! "$release_target" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "Error: Unable to resolve valid target commit for release '$tag' in $repo" >&2
exit 1
fi
if [[ "$release_target" != "$CAPTURED_SHA" ]]; then
echo "Error: Verified release target commit '$release_target' does not match CAPTURED_SHA '$CAPTURED_SHA'" >&2
exit 1
fi
for expected_asset in "${assets[@]}"; do
name="$(basename "$expected_asset")"
matches="$(printf '%s' "$release_json" | jq --arg n "$name" '[.assets[] | select(.name == $n)]')"
count="$(printf '%s' "$matches" | jq 'length')"
if [[ "$count" -ne 1 ]]; then
echo "Error: Expected asset '$name' present $count time(s) in release readback (must be exactly 1)" >&2
exit 1
fi
if [[ -z "$(printf '%s' "$matches" | jq -r '.[0].url // empty')" ]]; then
echo "Error: Expected asset '$name' has no usable URL in release readback" >&2
exit 1
fi
done
printf '%s\n' "$release_json"
)
From the JSON output returned by gh release view, extract the uploaded asset URLs and construct the comment body file (e.g. ${COMMENT_FILE:-$(~/.claude/skills/scratch-space/scripts/scratch-dir.sh tmp)/evidence_comment.md}). Do not guess draft asset download URLs or invent placeholder URLs.
Once the comment file is constructed, post the comment to the authorized PR:
(
set -euo pipefail
repo="${REPO:-}"
url_regex='^https://github\.com/([^/]+/[^/]+)/pull/([1-9][0-9]*)/?$'
if [[ -n "${PR_NUMBER_OR_URL:-}" ]]; then
if [[ "$PR_NUMBER_OR_URL" =~ $url_regex ]]; then
url_repo="${BASH_REMATCH[1]}"
url_pr="${BASH_REMATCH[2]}"
if [[ -n "$repo" && "$repo" != "$url_repo" ]]; then
echo "Error: Conflicting repository target '$repo' vs PR URL '$url_repo'" >&2
exit 1
fi
repo="${repo:-$url_repo}"
if [[ -n "${PR_NUMBER:-}" && "${PR_NUMBER}" != "$url_pr" ]]; then
echo "Error: Conflicting PR number '${PR_NUMBER}' vs PR URL '$url_pr'" >&2
exit 1
fi
PR_NUMBER="$url_pr"
elif [[ "$PR_NUMBER_OR_URL" =~ ^[1-9][0-9]*$ ]]; then
if [[ -n "${PR_NUMBER:-}" && "${PR_NUMBER}" != "$PR_NUMBER_OR_URL" ]]; then
echo "Error: Conflicting PR number '${PR_NUMBER}' vs PR_NUMBER_OR_URL '$PR_NUMBER_OR_URL'" >&2
exit 1
fi
PR_NUMBER="${PR_NUMBER:-$PR_NUMBER_OR_URL}"
else
echo "Error: PR_NUMBER_OR_URL must be a valid GitHub PR URL or positive PR number" >&2
exit 1
fi
fi
if [[ -n "${PR_NUMBER:-}" && "$PR_NUMBER" =~ $url_regex ]]; then
url_repo="${BASH_REMATCH[1]}"
url_pr="${BASH_REMATCH[2]}"
if [[ -n "$repo" && "$repo" != "$url_repo" ]]; then
echo "Error: Conflicting repository target '$repo' vs PR URL '$url_repo'" >&2
exit 1
fi
repo="${repo:-$url_repo}"
PR_NUMBER="$url_pr"
fi
if [[ -z "${PR_NUMBER:-}" || "$PR_NUMBER" == *"<"* || ! "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
echo "Error: PR_NUMBER must be set to a valid PR number before publication" >&2
exit 1
fi
if [[ -z "${repo:-}" || "$repo" == *"<"* ]]; then
echo "Error: REPO must be set to a valid owner/repo before publication" >&2
exit 1
fi
if [[ ! "$repo" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]]; then
echo "Error: REPO must be in the format 'owner/repo'" >&2
exit 1
fi
if [[ -z "${CAPTURED_SHA:-}" || "$CAPTURED_SHA" == *"<"* || ! "$CAPTURED_SHA" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "Error: CAPTURED_SHA must be set to a valid 40-character commit SHA" >&2
exit 1
fi
comment_scratch="$("${CLAUDE_HOME:-$HOME/.claude}/skills/scratch-space/scripts/scratch-dir.sh" tmp)"
comment_file="${COMMENT_FILE:-$comment_scratch/evidence_comment.md}"
if [ ! -s "$comment_file" ]; then
echo "Error: Comment body file '$comment_file' does not exist or is empty" >&2
exit 1
fi
# Verify exact intended PR before posting comment
pr_view_json="$(gh pr view "$PR_NUMBER" --repo "$repo" --json number,headRefOid,url)"
pr_number_resolved="$(printf '%s' "$pr_view_json" | jq -r '.number // empty')"
if [[ -n "$pr_number_resolved" && "$pr_number_resolved" != "$PR_NUMBER" ]]; then
echo "Error: Verified PR number mismatch ($pr_number_resolved vs $PR_NUMBER)" >&2
exit 1
fi
pr_head_sha="$(printf '%s' "$pr_view_json" | jq -r '.headRefOid // empty')"
if [[ -z "$pr_head_sha" || ! "$pr_head_sha" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "Error: Unable to resolve valid head SHA for PR #$PR_NUMBER in $repo" >&2
exit 1
fi
if [[ "$CAPTURED_SHA" != "$pr_head_sha" ]]; then
echo "Error: Declared CAPTURED_SHA '$CAPTURED_SHA' does not match verified PR head '$pr_head_sha'" >&2
exit 1
fi
target_pr="$PR_NUMBER"
gh pr comment "$target_pr" --repo "$repo" --body-file "$comment_file"
)
Behavior:
- Keeps publication fully zero-touch via
gh - Publishes durable GitHub-hosted release URLs for the
.gif,.mp4.zip, and captions - Avoids dependence on a browser session cookie
Optional path:
$HOME/.claude/scripts/github_pr_media_upload.pycan still be used when nativeuser-attachmentsURLs are explicitly desired and browser auth is available
Compression Guidance
GitHub free plans often cap video uploads at 10 MB. Compress when needed:
SCRATCH_TMP="$(~/.claude/skills/scratch-space/scripts/scratch-dir.sh tmp)" || {
echo "Scratch resolver unavailable; refusing compression" >&2
exit 75
}
[[ -n "$SCRATCH_TMP" ]] || {
echo "Scratch resolver returned an empty path; refusing compression" >&2
exit 75
}
ffmpeg -y -i "${SCRATCH_TMP}/${WORK_NAME:-work}.mp4" -vcodec h264 -crf 23 -preset medium "${SCRATCH_TMP}/${WORK_NAME:-work}.compressed.mp4"
Reviewer Checklist
A reviewer should reject evidence if any are missing:
- Pre/post SHA match
- Real command output (not echo-only)
- Captions present
- Sanitized logs (no machine-specific absolute paths)
- Media links accessible to the intended reviewer at an authorized destination
- Any publication uses the authorized destination and applicable automation workflow
- Matching metadata and captions in the reviewed evidence receipt
04 同仓库更多 Skills
disk-reclaim-playbook
Use Disk Magician to diagnose disk growth or qualify cleanup on macOS or Linux.
claudea-bench
Compare `claudea` and normal `claude` on a fair split of comparable work by default; use `--strict` for duplicate runs of the exact same task.
pr
Alias for the canonical pr-lifecycle PR workflow skill (/pr-workflow, /prw).
whisper
OpenAI's general-purpose speech recognition model. Supports 99 languages, transcription, translation to English, and language identification. Six model sizes from tiny (39M params) to large (1550M params). Use for speech-to-text, podcast transcription, or multilingual audio processing. Best for robust, multilingual ASR.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
pr-report
This skill should be used when the user asks for a PR report, PR audit, PR delta analysis, /pr-report, or wants per-PR summary with delta files/lines. Generates a structured report for one or more open PRs covering purpose, files changed, +/− line counts, /code-standards + /thermo review findings, /ponytail simplification opportunities, file-overlap combination candidates, and /green status per pr-green-definition. Output: machine-readable JSONL + human-readable markdown. Read-only by default; can apply simplifications if user opts in.