wtf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWTF
WTF
Single-pass situational awareness for the current git branch. Analyzes git state only -- no source file reads.
WriteEditReadGlobGrep为当前git分支提供一次性情境感知。仅分析git状态——不读取源文件。
WriteEditReadGlobGrepWorkflow
工作流程
Follow all 3 steps sequentially.
按顺序执行以下3个步骤。
Step 1: Detect Context
步骤1:检测上下文
-
Parse the optional focus argument from everything after.
/wtf- -> focus is "auth"
/wtf auth - (bare) -> no focus, full analysis
/wtf
-
Run a single Bash call to detect the git context:
bash
CURRENT=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
DETACHED=$?
if git rev-parse --verify main &>/dev/null; then TRUNK="main"
elif git rev-parse --verify master &>/dev/null; then TRUNK="master"
else TRUNK=""; fi
echo "CURRENT=$CURRENT"
echo "TRUNK=$TRUNK"
echo "DETACHED=$DETACHED"- Route based on the result:
- Not a git repo (commands fail) -> report "Not a git repository." and stop.
- Detached HEAD -> report the hash, run around that point, summarize, and stop.
git log --oneline -10 - No trunk found (is empty) -> use
TRUNKto ask the user for their trunk branch name, then continue.AskUserQuestion - On trunk () -> go to Step 2B.
CURRENT == TRUNK - Feature branch (anything else) -> go to Step 2A.
-
从之后的所有内容中解析可选的焦点参数。
/wtf- -> 焦点为“auth”
/wtf auth - (无参数)-> 无焦点,进行完整分析
/wtf
-
运行一次Bash调用以检测git上下文:
bash
CURRENT=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
DETACHED=$?
if git rev-parse --verify main &>/dev/null; then TRUNK="main"
elif git rev-parse --verify master &>/dev/null; then TRUNK="master"
else TRUNK=""; fi
echo "CURRENT=$CURRENT"
echo "TRUNK=$TRUNK"
echo "DETACHED=$DETACHED"- 根据结果进行分支处理:
- 非git仓库(命令执行失败)-> 报告“这不是git仓库。”并停止。
- 分离HEAD状态 -> 报告哈希值,运行查看该节点附近的提交,总结后停止。
git log --oneline -10 - 未找到主干分支(为空)-> 使用
TRUNK询问用户主干分支的名称,然后继续。AskUserQuestion - 当前在主干分支()-> 进入步骤2B。
CURRENT == TRUNK - 功能分支(其他情况)-> 进入步骤2A。
Step 2A: Feature Branch
步骤2A:功能分支
Run a single Bash call to collect all data at once:
bash
MERGE_BASE=$(git merge-base HEAD $TRUNK)
echo "=== LOG ==="
git log --format="%h %s%n%w(0,4,4)%b" $MERGE_BASE..HEAD
echo "=== STAT ==="
git diff --stat $MERGE_BASE..HEAD
echo "=== SHORTSTAT ==="
git diff --shortstat $MERGE_BASE..HEAD
echo "=== MERGE_BASE ==="
echo $MERGE_BASEIf a focus argument was provided, add path filtering:
- Append to the
-- '*{focus}*'andgit logcommandsgit diff --stat - If no results match the focus, report "No changes matching '{focus}'" and stop.
Edge case -- no divergence: If returns nothing (merge base == HEAD), report "Branch exists but hasn't diverged from {trunk} yet." and stop.
git logParse the output silently. Do NOT echo the raw git output. Proceed to Step 3A.
运行一次Bash调用一次性收集所有数据:
bash
MERGE_BASE=$(git merge-base HEAD $TRUNK)
echo "=== LOG ==="
git log --format="%h %s%n%w(0,4,4)%b" $MERGE_BASE..HEAD
echo "=== STAT ==="
git diff --stat $MERGE_BASE..HEAD
echo "=== SHORTSTAT ==="
git diff --shortstat $MERGE_BASE..HEAD
echo "=== MERGE_BASE ==="
echo $MERGE_BASE如果提供了焦点参数,添加路径过滤:
- 在和
git log命令后追加git diff --stat-- '*{focus}*' - 如果没有匹配焦点的结果,报告“没有找到匹配'{focus}'的变更”并停止。
边缘情况——无分歧: 如果无返回结果(合并基准与HEAD一致),报告“分支已存在,但尚未与{trunk}产生分歧。”并停止。
git log静默解析输出。不要回显原始git输出。继续执行步骤3A。
Step 2B: Trunk Branch
步骤2B:主干分支
Run a single Bash call:
bash
echo "=== RECENT ==="
git log --oneline --since="7 days ago" --format="%h %s (%an, %ar)"
echo "=== COUNT ==="
git rev-list --count --since="7 days ago" HEADParse the output:
- Filter out routine commits (dependency bumps, CI config, docs-only, formatting, merge commits).
- Group remaining interesting commits by day.
- Count filtered-out commits separately.
Edge case -- no recent activity: If count is 0, expand the window to 30 days and re-run. If still 0, report "Quiet repo -- no commits in the last 30 days." and stop.
Parse the output silently. Do NOT echo the raw git output. Proceed to Step 3B.
运行一次Bash调用:
bash
echo "=== RECENT ==="
git log --oneline --since="7 days ago" --format="%h %s (%an, %ar)"
echo "=== COUNT ==="
git rev-list --count --since="7 days ago" HEAD解析输出:
- 过滤掉常规提交(依赖更新、CI配置、仅文档变更、格式调整、合并提交)。
- 将剩余的重要提交按天分组。
- 单独统计被过滤掉的提交数量。
边缘情况——近期无活动: 如果数量为0,将时间窗口扩大到30天并重新运行。如果仍然为0,报告“仓库近期无活动——过去30天内没有提交。”并停止。
静默解析输出。不要回显原始git输出。继续执行步骤3B。
Step 3A: Present (Feature Branch)
步骤3A:展示(功能分支)
Output in this exact format:
markdown
undefined严格按照以下格式输出:
markdown
undefinedWTF: {branch-name}
WTF: {分支名称}
Purpose: {one-sentence description of what this branch does, inferred from commit messages}
Base: diverged from {trunk} at {merge-base-short} ({N} commits ahead)
Scope: {files changed} files | +{insertions} -{deletions}
用途: {从提交信息推断出的该分支用途的一句话描述}
基准: 从{trunk}分支在{merge-base-short}节点分歧(超前{N}个提交)
范围: {变更文件数}个文件 | +{新增行数} -{删除行数}
Changes
变更内容
- {2-5 bullets summarizing logical changes, grouped by concern}
- {2-5个要点,按关注点分组总结逻辑变更}
Key Files
关键文件
| File | Change | What |
|---|---|---|
| {path} | +n/-n | {one-line description} |
Next:
- Show the full diff
- Deep-dive into a specific file
- something specific
/check
undefined| 文件 | 变更 | 说明 |
|---|---|---|
| {路径} | +n/-n | 一行描述 |
下一步可选操作:
- 查看完整差异
- 深入分析特定文件
- 特定内容
/check
undefinedStep 3B: Present (Trunk Branch)
步骤3B:展示(主干分支)
Output in this exact format:
markdown
undefined严格按照以下格式输出:
markdown
undefinedWTF: {trunk-branch}
WTF: {主干分支名称}
{N} commits in the last 7 days.
过去7天内有{N}个提交。
Highlights
重点内容
{Day}
- {hash} {summary} ({author})
{日期}
- {哈希值} {提交摘要}({作者})
Filtered Out
已过滤内容
{N} routine commits omitted (deps, CI, docs).
What do you want to look at?
- A specific commit
- A different time range
- Changes by a specific author
- A specific area of the codebase
undefined已忽略{N}个常规提交(依赖、CI、文档)。
你想查看什么内容?
- 特定提交
- 不同的时间范围
- 特定作者的变更
- 代码库的特定区域
undefinedGuidelines
指导原则
- This skill is strictly read-only. Never suggest running a write operation.
- No subagents. This skill is too simple for Task delegation.
- Parse git output silently and present structured markdown. Never dump raw git output to the user.
- Keep the total output concise. This is a quick orientation, not a full audit.
- If focus argument is provided, scope everything to that filter. Report clearly when the filter has no matches.
- For the Key Files table in feature branch output, limit to the 8 most-changed files. If there are more, add a summary row like "... and {N} more files".
- 本技能严格为只读模式。绝不建议执行写入操作。
- 不使用子代理。本技能过于简单,无需任务委托。
- 静默解析git输出并展示结构化的markdown内容。绝不向用户输出原始git内容。
- 保持整体输出简洁。这是快速概览,而非完整审计。
- 如果提供了焦点参数,所有内容都限定在该过滤条件内。当过滤无匹配结果时,需清晰告知用户。
- 在功能分支输出的“关键文件”表格中,最多展示8个变更最频繁的文件。如果更多,添加一行摘要如“... 以及{N}个其他文件”。