ecosystem
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEcosystem Audit
生态系统审计
On-demand audit of the Claude Code ecosystem. Runs 4 checks, prints a full report with an attention summary, and appends a summary to today's daily note.
按需审计Claude Code生态系统。运行4项检查,打印包含重点摘要的完整报告,并将摘要追加到今日的每日笔记中。
Workflow
工作流程
Run all 4 checks sequentially using the bash blocks below. Each block runs in a fresh shell, so after all checks complete, compose the daily note summary and attention rollup from the terminal output you've collected.
CRITICAL: Run before writing to the daily note.
date +"%Y%m%d"使用下方的bash代码块依次运行所有4项检查。每个代码块在全新的shell中运行,因此所有检查完成后,需从收集到的终端输出中撰写每日笔记摘要和重点汇总。
重要提示:写入每日笔记前,请先运行。
date +"%Y%m%d"Step 1: Skill Health
步骤1:技能健康度
Scan for skill freshness and broken symlinks.
~/.claude/skills/bash
NOW=$(date +%s)
D30=$((NOW - 30*86400))
D90=$((NOW - 90*86400))
ACTIVE="" BROKEN=""
ACTIVE_N=0 RECENT_N=0 STALE_N=0 BROKEN_N=0 TOTAL=0
for entry in ~/.claude/skills/*/; do
[ -d "$entry" ] || continue
name=$(basename "$entry")
TOTAL=$((TOTAL + 1))
if [ -L "${entry%/}" ] && [ ! -e "${entry%/}" ]; then
target=$(readlink "${entry%/}")
BROKEN="${BROKEN} - ${name} -> ${target}\n"
BROKEN_N=$((BROKEN_N + 1))
continue
fi
real_path="$entry"
if [ -L "${entry%/}" ]; then
real_path="$(readlink "${entry%/}")/"
fi
newest=$(find "$real_path" -type f -exec stat -f %m {} + 2>/dev/null | sort -rn | head -1)
[ -z "$newest" ] && newest=0
if [ "$newest" -ge "$D30" ]; then
ACTIVE="${ACTIVE}, ${name}"
ACTIVE_N=$((ACTIVE_N + 1))
elif [ "$newest" -ge "$D90" ]; then
RECENT_N=$((RECENT_N + 1))
else
STALE_N=$((STALE_N + 1))
fi
done
echo "### Skills (${TOTAL} total)"
echo "- Active (30d): ${ACTIVE_N}${ACTIVE:+ — ${ACTIVE:2}}"
echo "- Recent (30-90d): ${RECENT_N}"
echo "- Stale (>90d): ${STALE_N}"
echo "- Broken symlinks: ${BROKEN_N}"
[ -n "$BROKEN" ] && printf "$BROKEN"扫描目录,检查技能的新鲜度和损坏的符号链接。
~/.claude/skills/bash
NOW=$(date +%s)
D30=$((NOW - 30*86400))
D90=$((NOW - 90*86400))
ACTIVE="" BROKEN=""
ACTIVE_N=0 RECENT_N=0 STALE_N=0 BROKEN_N=0 TOTAL=0
for entry in ~/.claude/skills/*/; do
[ -d "$entry" ] || continue
name=$(basename "$entry")
TOTAL=$((TOTAL + 1))
if [ -L "${entry%/}" ] && [ ! -e "${entry%/}" ]; then
target=$(readlink "${entry%/}")
BROKEN="${BROKEN} - ${name} -> ${target}\n"
BROKEN_N=$((BROKEN_N + 1))
continue
fi
real_path="$entry"
if [ -L "${entry%/}" ]; then
real_path="$(readlink "${entry%/}")/"
fi
newest=$(find "$real_path" -type f -exec stat -f %m {} + 2>/dev/null | sort -rn | head -1)
[ -z "$newest" ] && newest=0
if [ "$newest" -ge "$D30" ]; then
ACTIVE="${ACTIVE}, ${name}"
ACTIVE_N=$((ACTIVE_N + 1))
elif [ "$newest" -ge "$D90" ]; then
RECENT_N=$((RECENT_N + 1))
else
STALE_N=$((STALE_N + 1))
fi
done
echo "### Skills (${TOTAL} total)"
echo "- Active (30d): ${ACTIVE_N}${ACTIVE:+ — ${ACTIVE:2}}"
echo "- Recent (30-90d): ${RECENT_N}"
echo "- Stale (>90d): ${STALE_N}"
echo "- Broken symlinks: ${BROKEN_N}"
[ -n "$BROKEN" ] && printf "$BROKEN"Step 2: Project Pulse
步骤2:项目活动状态
Scan for git repo activity and CLAUDE.md presence. Cap dormant and abandoned lists at 10 names to keep output readable.
~/ai_projects/bash
NOW=$(date +%s)
D30=$((NOW - 30*86400))
D180=$((NOW - 180*86400))
ACTIVE="" DORMANT="" ABANDONED="" DORMANT_N=0 ABANDONED_N=0 NO_CLAUDE=0
ACTIVE_N=0 GIT_TOTAL=0 DIR_TOTAL=0 NODATA=0
for dir in ~/ai_projects/*/; do
[ -d "$dir" ] || continue
DIR_TOTAL=$((DIR_TOTAL + 1))
[ -d "${dir}.git" ] || continue
GIT_TOTAL=$((GIT_TOTAL + 1))
last_commit=$(git -C "$dir" log -1 --format=%ct 2>/dev/null)
if [ -z "$last_commit" ]; then
NODATA=$((NODATA + 1))
continue
fi
name=$(basename "$dir")
if [ "$last_commit" -ge "$D30" ]; then
ACTIVE="${ACTIVE}, ${name}"
ACTIVE_N=$((ACTIVE_N + 1))
elif [ "$last_commit" -ge "$D180" ]; then
DORMANT_N=$((DORMANT_N + 1))
[ "$DORMANT_N" -le 10 ] && DORMANT="${DORMANT}, ${name}"
else
ABANDONED_N=$((ABANDONED_N + 1))
[ "$ABANDONED_N" -le 10 ] && ABANDONED="${ABANDONED}, ${name}"
fi
[ ! -f "${dir}CLAUDE.md" ] && NO_CLAUDE=$((NO_CLAUDE + 1))
done
DORMANT_SUFFIX=""
[ "$DORMANT_N" -gt 10 ] && DORMANT_SUFFIX=" and $((DORMANT_N - 10)) more"
ABANDONED_SUFFIX=""
[ "$ABANDONED_N" -gt 10 ] && ABANDONED_SUFFIX=" and $((ABANDONED_N - 10)) more"
echo ""
echo "### Projects (${DIR_TOTAL} dirs, ${GIT_TOTAL} git repos)"
echo "- Active (30d): ${ACTIVE_N}${ACTIVE:+ — ${ACTIVE:2}}"
echo "- Dormant (30-180d): ${DORMANT_N}${DORMANT:+ — ${DORMANT:2}${DORMANT_SUFFIX}}"
echo "- Abandoned (>6mo): ${ABANDONED_N}${ABANDONED:+ — ${ABANDONED:2}${ABANDONED_SUFFIX}}"
[ "$NODATA" -gt 0 ] && echo "- No data (empty/corrupt): ${NODATA}"
echo "- Missing CLAUDE.md: ${NO_CLAUDE}"扫描目录,检查git仓库活动情况和CLAUDE.md文件是否存在。为保持输出可读性,休眠和废弃项目列表最多显示10个名称。
~/ai_projects/bash
NOW=$(date +%s)
D30=$((NOW - 30*86400))
D180=$((NOW - 180*86400))
ACTIVE="" DORMANT="" ABANDONED="" DORMANT_N=0 ABANDONED_N=0 NO_CLAUDE=0
ACTIVE_N=0 GIT_TOTAL=0 DIR_TOTAL=0 NODATA=0
for dir in ~/ai_projects/*/; do
[ -d "$dir" ] || continue
DIR_TOTAL=$((DIR_TOTAL + 1))
[ -d "${dir}.git" ] || continue
GIT_TOTAL=$((GIT_TOTAL + 1))
last_commit=$(git -C "$dir" log -1 --format=%ct 2>/dev/null)
if [ -z "$last_commit" ]; then
NODATA=$((NODATA + 1))
continue
fi
name=$(basename "$dir")
if [ "$last_commit" -ge "$D30" ]; then
ACTIVE="${ACTIVE}, ${name}"
ACTIVE_N=$((ACTIVE_N + 1))
elif [ "$last_commit" -ge "$D180" ]; then
DORMANT_N=$((DORMANT_N + 1))
[ "$DORMANT_N" -le 10 ] && DORMANT="${DORMANT}, ${name}"
else
ABANDONED_N=$((ABANDONED_N + 1))
[ "$ABANDONED_N" -le 10 ] && ABANDONED="${ABANDONED}, ${name}"
fi
[ ! -f "${dir}CLAUDE.md" ] && NO_CLAUDE=$((NO_CLAUDE + 1))
done
DORMANT_SUFFIX=""
[ "$DORMANT_N" -gt 10 ] && DORMANT_SUFFIX=" and $((DORMANT_N - 10)) more"
ABANDONED_SUFFIX=""
[ "$ABANDONED_N" -gt 10 ] && ABANDONED_SUFFIX=" and $((ABANDONED_N - 10)) more"
echo ""
echo "### Projects (${DIR_TOTAL} dirs, ${GIT_TOTAL} git repos)"
echo "- Active (30d): ${ACTIVE_N}${ACTIVE:+ — ${ACTIVE:2}}"
echo "- Dormant (30-180d): ${DORMANT_N}${DORMANT:+ — ${DORMANT:2}${DORMANT_SUFFIX}}"
echo "- Abandoned (>6mo): ${ABANDONED_N}${ABANDONED:+ — ${ABANDONED:2}${ABANDONED_SUFFIX}}"
[ "$NODATA" -gt 0 ] && echo "- No data (empty/corrupt): ${NODATA}"
echo "- Missing CLAUDE.md: ${NO_CLAUDE}"Step 3: CLAUDE.md Drift
步骤3:CLAUDE.md漂移
Check if CLAUDE.md files are stale relative to their project's latest commit. Uses git commit dates (not filesystem mtime) for accuracy.
bash
NOW=$(date +%s)
STALE_LIST="" STALE_N=0
UNTRACKED_LIST="" UNTRACKED_N=0
while IFS= read -r claude_file; do
project_dir=$(dirname "$claude_file")
while [ ! -d "${project_dir}/.git" ] && [ "$project_dir" != "$HOME/ai_projects" ]; do
project_dir=$(dirname "$project_dir")
done
[ -d "${project_dir}/.git" ] || continue
claude_commit=$(git -C "$project_dir" log -1 --format=%ct -- "$claude_file" 2>/dev/null)
project_commit=$(git -C "$project_dir" log -1 --format=%ct 2>/dev/null)
[ -z "$project_commit" ] && continue
if [ -z "$claude_commit" ]; then
rel_path="${claude_file#$HOME/}"
UNTRACKED_LIST="${UNTRACKED_LIST} - ~/${rel_path}\n"
UNTRACKED_N=$((UNTRACKED_N + 1))
continue
fi
diff=$((project_commit - claude_commit))
if [ "$diff" -gt $((90*86400)) ]; then
rel_path="${claude_file#$HOME/}"
claude_date=$(date -r "$claude_commit" +%Y-%m-%d)
project_date=$(date -r "$project_commit" +%Y-%m-%d)
STALE_LIST="${STALE_LIST} - ~/${rel_path} (last: ${claude_date}, project: ${project_date})\n"
STALE_N=$((STALE_N + 1))
fi
done < <(find ~/ai_projects -maxdepth 2 -name CLAUDE.md 2>/dev/null)
echo ""
echo "### CLAUDE.md Drift"
echo "- Stale instructions (>90d behind project): ${STALE_N}"
[ -n "$STALE_LIST" ] && printf "$STALE_LIST"
echo "- Untracked: ${UNTRACKED_N}"
[ -n "$UNTRACKED_LIST" ] && printf "$UNTRACKED_LIST"检查CLAUDE.md文件是否相对于项目最新提交已陈旧。为确保准确性,使用git提交日期(而非文件系统修改时间)进行判断。
bash
NOW=$(date +%s)
STALE_LIST="" STALE_N=0
UNTRACKED_LIST="" UNTRACKED_N=0
while IFS= read -r claude_file; do
project_dir=$(dirname "$claude_file")
while [ ! -d "${project_dir}/.git" ] && [ "$project_dir" != "$HOME/ai_projects" ]; do
project_dir=$(dirname "$project_dir")
done
[ -d "${project_dir}/.git" ] || continue
claude_commit=$(git -C "$project_dir" log -1 --format=%ct -- "$claude_file" 2>/dev/null)
project_commit=$(git -C "$project_dir" log -1 --format=%ct 2>/dev/null)
[ -z "$project_commit" ] && continue
if [ -z "$claude_commit" ]; then
rel_path="${claude_file#$HOME/}"
UNTRACKED_LIST="${UNTRACKED_LIST} - ~/${rel_path}\n"
UNTRACKED_N=$((UNTRACKED_N + 1))
continue
fi
diff=$((project_commit - claude_commit))
if [ "$diff" -gt $((90*86400)) ]; then
rel_path="${claude_file#$HOME/}"
claude_date=$(date -r "$claude_commit" +%Y-%m-%d)
project_date=$(date -r "$project_commit" +%Y-%m-%d)
STALE_LIST="${STALE_LIST} - ~/${rel_path} (last: ${claude_date}, project: ${project_date})\n"
STALE_N=$((STALE_N + 1))
fi
done < <(find ~/ai_projects -maxdepth 2 -name CLAUDE.md 2>/dev/null)
echo ""
echo "### CLAUDE.md Drift"
echo "- Stale instructions (>90d behind project): ${STALE_N}"
[ -n "$STALE_LIST" ] && printf "$STALE_LIST"
echo "- Untracked: ${UNTRACKED_N}"
[ -n "$UNTRACKED_LIST" ] && printf "$UNTRACKED_LIST"Step 4: Mac Mini Health
步骤4:Mac Mini健康状态
SSH to agents-mac-mini and check services. Uses to avoid pseudo-tty and prefix to filter iTerm escape codes from the output.
-TECOSYS:Custom services on the Mac Mini use various prefixes (, , , , , , etc.), so count all non-Apple LaunchAgents.
com.server.*com.telegram-agent.*com.photopulse.*com.health.*com.temporal.*ai.hermes.*bash
echo ""
echo "### Mac Mini"
MINI_OUTPUT=$(ssh -T -o ConnectTimeout=5 -o BatchMode=yes mac-mini 'export TERM=dumb; thumb=$(curl -s --max-time 3 -o /dev/null -w "%{http_code}" http://localhost:8080/ 2>/dev/null); viz=$(curl -s --max-time 3 -o /dev/null -w "%{http_code}" http://localhost:8081/ 2>/dev/null); agents=$(launchctl list 2>/dev/null | tail -n +2 | awk "{print \$3}" | grep -cv "^com\.apple" || echo 0); hdb_size=$(stat -f %z ~/ai_projects/health-import/health.db 2>/dev/null || echo 0); echo "ECOSYS:${thumb}|${viz}|${agents}|${hdb_size}"' 2>/dev/null)
DATA=$(echo "$MINI_OUTPUT" | grep "^ECOSYS:" | sed 's/^ECOSYS://')
if [ -z "$DATA" ]; then
echo "- Status: UNREACHABLE (SSH failed)"
else
IFS='|' read -r THUMB VIZ AGENTS HDB_SIZE <<< "$DATA"
[ "$THUMB" = "200" ] && echo "- Thumb server (:8080): UP" || echo "- Thumb server (:8080): DOWN (${THUMB})"
[ "$VIZ" = "200" ] && echo "- Viz server (:8081): UP" || echo "- Viz server (:8081): DOWN (${VIZ})"
echo "- Custom LaunchAgents: ${AGENTS}"
if [ "$HDB_SIZE" -gt 0 ] 2>/dev/null; then
HDB_GB=$(echo "scale=1; ${HDB_SIZE}/1073741824" | bc)
echo "- Health DB: ${HDB_GB} GB"
else
echo "- Health DB: NOT FOUND"
fi
fi通过SSH连接到agents-mac-mini并检查服务状态。使用选项避免伪终端,使用前缀过滤iTerm转义码。
-TECOSYS:Mac Mini上的自定义服务使用多种前缀(、、、、、等),因此统计所有非Apple的LaunchAgents。
com.server.*com.telegram-agent.*com.photopulse.*com.health.*com.temporal.*ai.hermes.*bash
echo ""
echo "### Mac Mini"
MINI_OUTPUT=$(ssh -T -o ConnectTimeout=5 -o BatchMode=yes mac-mini 'export TERM=dumb; thumb=$(curl -s --max-time 3 -o /dev/null -w "%{http_code}" http://localhost:8080/ 2>/dev/null); viz=$(curl -s --max-time 3 -o /dev/null -w "%{http_code}" http://localhost:8081/ 2>/dev/null); agents=$(launchctl list 2>/dev/null | tail -n +2 | awk "{print \$3}" | grep -cv "^com\.apple" || echo 0); hdb_size=$(stat -f %z ~/ai_projects/health-import/health.db 2>/dev/null || echo 0); echo "ECOSYS:${thumb}|${viz}|${agents}|${hdb_size}"' 2>/dev/null)
DATA=$(echo "$MINI_OUTPUT" | grep "^ECOSYS:" | sed 's/^ECOSYS://')
if [ -z "$DATA" ]; then
echo "- Status: UNREACHABLE (SSH failed)"
else
IFS='|' read -r THUMB VIZ AGENTS HDB_SIZE <<< "$DATA"
[ "$THUMB" = "200" ] && echo "- Thumb server (:8080): UP" || echo "- Thumb server (:8080): DOWN (${THUMB})"
[ "$VIZ" = "200" ] && echo "- Viz server (:8081): UP" || echo "- Viz server (:8081): DOWN (${VIZ})"
echo "- Custom LaunchAgents: ${AGENTS}"
if [ "$HDB_SIZE" -gt 0 ] 2>/dev/null; then
HDB_GB=$(echo "scale=1; ${HDB_SIZE}/1073741824" | bc)
echo "- Health DB: ${HDB_GB} GB"
else
echo "- Health DB: NOT FOUND"
fi
fiStep 5: Attention Summary + Daily Note
步骤5:重点摘要 + 每日笔记
After printing the full terminal report, add an attention summary highlighting anything that needs action:
undefined打印完整的终端报告后,添加重点摘要,突出显示所有需要处理的内容:
undefinedAttention
重点关注
- [list any: broken symlinks, services DOWN, stale CLAUDE.md, Mac Mini unreachable]
- If nothing needs attention: "All clear."
Then compose a summary and write it to today's daily note.
Get today's date first:
```bash
TODAY=$(date +"%Y%m%d")Build the summary block from the results you collected in Steps 1-4 (re-read the terminal output above — variables don't carry across bash blocks). Format:
markdown
undefined- [列出以下内容:损坏的符号链接、已停止的服务、陈旧的CLAUDE.md、Mac Mini无法连接]
- 若无需要处理的内容:"一切正常。"
然后撰写摘要并写入今日的每日笔记。
首先获取今日日期:
```bash
TODAY=$(date +"%Y%m%d")从步骤1-4收集的结果中构建摘要块(重新阅读上方的终端输出——变量不会跨bash块传递)。格式如下:
markdown
undefinedEcosystem
Ecosystem
Skills: N active / N recent / N stale / N broken
Projects: N active / N dormant / N abandoned
CLAUDE.md drift: N stale, N untracked
Mac Mini: [status summary]
Ecosystem audit · YYYY-MM-DD
Write to `~/Brains/brain/Daily/${TODAY}.md`:
- If `## Ecosystem` section already exists, replace everything from `## Ecosystem` to the next `##` heading (or `- - -` separator)
- If it doesn't exist, insert above the first `- - -` separator
- If any red flags (broken symlinks > 0, services down, stale CLAUDE.md > 3), prepend `> [!warning] Ecosystem issues detected`Skills: N active / N recent / N stale / N broken
Projects: N active / N dormant / N abandoned
CLAUDE.md drift: N stale, N untracked
Mac Mini: [状态摘要]
Ecosystem audit · YYYY-MM-DD
写入`~/Brains/brain/Daily/${TODAY}.md`:
- 若`## Ecosystem`部分已存在,替换从`## Ecosystem`到下一个`##`标题(或`- - -`分隔符)之间的所有内容
- 若不存在,插入到第一个`- - -`分隔符上方
- 若存在任何红色警报(损坏的符号链接>0、服务停止、陈旧CLAUDE.md>3),在开头添加`> [!warning] Ecosystem issues detected`