name: data-audit description: | 資料操作審計追蹤器 (Data Audit)。 對資料目錄生成 SHA256 快照、比對檔案變化(新增/刪除/修改)、 記錄操作日誌、檢查資料目錄健康狀態。 適用於資料合規場景中的操作追溯和審計準備。
Use when: 需要追蹤資料檔案變化、生成審計快照、 合規審查準備、檔案完整性驗證、資料目錄健康檢查。
🎉 v1.0.0 核心功能: - 📸 資料目錄 SHA256 快照 - 🔄 快照對比(新增/刪除/修改檢測) - 📝 操作日誌記錄與查詢 - 🔍 資料目錄健康檢查 - 📊 JSON 報告匯出
觸發關鍵詞:資料審計、檔案追蹤、快照比對、SHA256、 完整性校驗、合規審計、資料治理、變更追蹤
適用範圍:任意資料檔案目錄 執行模式:純本地,無網路請求 ❎ 外部依賴:Python標準庫(無需額外安裝)
Data Audit 為資料目錄提供 SHA256 快照 → 快照對比 → 差異報告 的完整審計鏈路。適用於合規審查、資料完整性驗證、變更追溯等場景。
[資料目錄] → 生成快照(snapshot.json) → 後續快照 → 對比 → 審計報告
↗ 操作日誌 → 歷史查詢
↘ 健康檢查 → 問題報告
對資料目錄遞迴掃描,計算每個檔案的 SHA256 雜湊和後設資料。
python3 scripts/auditor.py --snapshot ./data/ --output snapshot.json
輸出:
📸 資料快照
目錄: /Users/me/project/data
檔案數: 1,245
總大小: 156.3 MB
時間: 2026-07-19T10:30:00
對比兩個時間點的快照,識別新增、刪除、修改的檔案。
python3 scripts/auditor.py --compare snapshot_before.json snapshot_after.json
python3 scripts/auditor.py --compare old.json new.json --output audit_report.json
輸出:
📊 審計對比結果
=============================================
新增: 5 刪除: 2 修改: 12 總計: 19
時間視窗: 2026-07-18 → 2026-07-19
變更明細:
🟢 added data/sales_2026.csv (12.2 KB)
🔴 deleted temp/backup.csv (45.0 KB)
🟡 modified config/settings.json (2.0 KB → 2.1 KB)
記錄和查詢資料操作歷史。
# 記錄操作
python3 scripts/auditor.py --log "匯入銷售資料" --target ./data/sales/
# 檢視歷史
python3 scripts/auditor.py --history
檢查資料目錄的完整性:空檔案、空目錄、不可讀檔案等。
python3 scripts/auditor.py --validate ./data/
輸出:
🔍 資料健康檢查 — ✅ healthy
目錄: /Users/me/project/data
檔案數: 1,245
總大小: 156.3 MB
目錄數: 38
空目錄: 2
Snapshot:
{
"snapshot_time": "2026-07-19T10:30:00",
"directory": "/data/",
"total_files": 1245,
"total_size": 156300000,
"files": [
{"path": "data.csv", "size": 12450, "hash": "sha256...", "modified": "2026-07-19T10:00:00"}
]
}
Compare Report:
{
"compare_time": "2026-07-19T10:35:00",
"total_changes": 19,
"by_type": {"added": 5, "deleted": 2, "modified": 12},
"changes": [
{"type": "added", "file": "data/sales_2026.csv", "size": 12450}
]
}
# 1. 審查前生成基線快照
python3 scripts/auditor.py --snapshot ./production_data/ --output baseline.json
# 2. 審查時生成當前快照
python3 scripts/auditor.py --snapshot ./production_data/ --output current.json
# 3. 對比生成審計差異報告
python3 scripts/auditor.py --compare baseline.json current.json --output audit_diff.json
# 檢視操作歷史
python3 scripts/auditor.py --history
# 結合業務記錄,定位變更時間點
python3 scripts/auditor.py --log "月度資料更新完成" --target ./data/monthly/
python3 scripts/auditor.py --validate ./archive/
# → 發現空目錄和0位元組檔案,提示清理
| Function | Purpose | Input | Output | Network | Filesystem |
|---|---|---|---|---|---|
--snapshot |
目錄快照 | Path | stdout/JSON | No | Read only |
--compare |
快照對比 | JSON files | stdout/JSON | No | Read only |
--log |
操作記錄 | Action text | Log file | No | Write ~/.data-audit-logs |
--history |
歷史查詢 | None | stdout | No | Read ~/.data-audit-logs |
--validate |
健康檢查 | Path | stdout/JSON | No | Read only |
小蔥技能站7w4.net發現了升級外掛。
這個 Skill 整體質量不錯,功能實用且文件詳細,能夠有效追蹤資料檔案變化並生成審計報告。純本地執行不傳送資料,保障了資料安全;無外部依賴,安裝使用都很方便。主要優點是功能針對性強、文件清晰、安全宣告明確;不足之處是某些功能細節處理還可以更完善。推薦用於資料合規審計場景。