用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill claude-flow-hook-customizing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Token-efficient tracking for AI orchestration. CLI-first for status updates (~50 tokens), agent fallback for complex ops (~1KB). Use when: updating task status, querying blockers, creating progress files, validating phases.
AshAi extension guidelines for integrating AI capabilities with Ash Framework. Use when implementing vectorization/embeddings, exposing Ash actions as LLM tools, creating prompt-backed actions, or setting up MCP servers. Covers semantic search, LangChain integration, and structured outputs.
This skill should be used when solving hard questions, complex architectural problems, or debugging issues that benefit from GPT-5 Pro or GPT-5.1 thinking models with large file context. Use when standard Claude analysis needs deeper reasoning or extended context windows.
基于 SOC 职业分类
正在显示 SKILL.md
| name | claude-flow-hook-customizing |
| description | Use this skill when creating, optimizing, or maintaining claude hooks. |
A Complete Guide to Verification Hooks with Claude Flow
This guide demonstrates how to use Claude Code's hook system to ensure AI agents create real, functional, and secure code - not mocks or simulations. The hooks provide both preventive guidance (before edits) and verification feedback (after edits) to maintain code quality.
REFERENCE.md
./examples/memory-workflow-mcp.js ./examples/session-memory-workflow.sh
One of the hardest problems in fast-moving development is that things slip through the cracks:
console.log left behindBy the time it hits production, you're firefighting instead of building.
Make verification automatic, not optional. That's where Claude Flow verification hooks come in.
This tutorial shows you how to wire up Claude Code PreToolUse and PostToolUse hooks that keep your coding agents on track using the Claude Flow Truth and Verification tools.
💡 Think of it as: Having a senior developer quietly checking over your shoulder every time you hit save, but without slowing you down.
// api/users.js
const API_KEY = "sk-prod-12345"; // Quick fix for now
const password = "admin123";
function getUserData() {
// TODO: Implement real database call
console.log("Mock response for testing");
return { mock: true, data: "placeholder" };
}
fetch("http://api.example.com/users"); // Will fix SSL later
🎯 PRE-EDIT VERIFICATION
Target: /api/users.js
⚠️ REQUIREMENTS:
• Real implementations only (no mocks in production)
• No hardcoded secrets - use environment variables
• Complete error handling
• Secure protocols (HTTPS)
🔍 Mandatory Verification Checklist:
✓ Implementation MUST be FULLY FUNCTIONAL
✓ NO mocks/stubs/simulations (unless test file)
✓ Real API connections (not placeholders)
✓ Actual data persistence (not in-memory only)
✓ Complete error handling (not just happy path)
✓ Production-ready code (not proof-of-concept)
🔐 Security Requirements:
⚠️ NEVER hardcode credentials or secrets
⚠️ Use environment variables for sensitive data
⚠️ No API keys, passwords, or tokens in code
⚠️ Validate and sanitize ALL user inputs
⚠️ Use secure connection protocols (HTTPS/TLS)
⚠️ Implement proper authentication & authorization
🚫 REJECT IF YOU SEE:
• Hardcoded: API_KEY="sk-..."
• Direct secrets: password="admin123"
• TODO/FIXME without implementation
• return mockData or simulatedResponse
• console.log with sensitive data
• Unvalidated user inputs (SQL injection risk)
• HTTP instead of HTTPS for APIs
✅ POST-EDIT ANALYSIS
Modified: /api/users.js
Checking for issues...
⚠️ TODO comments found
⚠️ console.log detected
🚨 Hardcoded password!
📊 CODE QUALITY ANALYSIS
File: /api/users.js
❌ TODO found (-15)
⚠️ console.log (-5)
❌ Mock detected (-25)
🚨 Hardcoded API key (-30)
🚨 Hardcoded password (-30)
⚠️ Insecure HTTP protocol (-10)
📊 QUALITY SCORE: -15/100
🚫 BELOW THRESHOLD (95) - Review required!
🔧 REQUIRED ACTIONS:
1. Fix all security issues immediately
2. Replace mocks with real implementations
3. Use environment variables for secrets
4. Remove debug statements
🔬 CLAUDE FLOW VERIFICATION
Truth Score: 0.45
Status: ❌ FAILED - Below 0.95 threshold
// api/users.js
const API_KEY = process.env.API_KEY;
const password = process.env.DB_PASSWORD;
async function getUserData() {
try {
const response = await fetch("https://api.example.com/users", {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
return await response.json();
} catch (error) {
logger.error('Failed to fetch user data:', error);
throw new Error('Unable to retrieve user data');
}
}
Claude Code's hook system fires at specific points:
| Hook Type | When it Fires | Purpose |
|---|---|---|
| PreToolUse | BEFORE tools execute | Preventive guidance & requirements |
| PostToolUse | AFTER tools complete | Verification & scoring |
| UserPromptSubmit | When you send a message | Automated feedback to Claude |
First, create a script to handle complex security checks without quote escaping issues:
# Create .claude/hook-analyzer-v2.sh
cat > .claude/hook-analyzer-v2.sh << 'EOF'
#!/bin/bash
# Enhanced hook analyzer with dynamic Claude Flow integration
FILE="$1"
echo "✅ POST-EDIT ANALYSIS" | tee -a /tmp/claude-hooks.log
echo "Modified: $FILE" | tee -a /tmp/claude-hooks.log
echo "Security Check Results:" | tee -a /tmp/claude-hooks.log
# Check for TODOs
if grep -q 'TODO' "$FILE" 2>/dev/null; then
echo " ⚠️ TODO found" | tee -a /tmp/claude-hooks.log
else
echo " ✓ No TODOs" | tee -a /tmp/claude-hooks.log
fi
# Check for console.log
if grep -q 'console.log' "$FILE" 2>/dev/null; then
echo " ⚠️ console.log found" | tee -a /tmp/claude-hooks.log
else
echo " ✓ No console.log" | tee -a /tmp/claude-hooks.log
fi
# Check for hardcoded secrets (improved regex)
if grep -qiE '(password|secret|token|key|credential)[[:space:]]*=[[:space:]]*["' 2>/dev/null;
| -a /tmp/claude-hooks.log
| -a /tmp/claude-hooks.log
-v npx >/dev/null 2>&1;
| -a /tmp/claude-hooks.log
| -a /tmp/claude-hooks.log
VERIFY_OUTPUT=$(npx claude-flow@alpha verify verify --agent coder --threshold 0.95 2>&1)
| grep -E | line;
| -a /tmp/claude-hooks.log
TRUTH_JSON=$(npx claude-flow@alpha truth --json 2>/dev/null)
[ $? -eq 0 ];
AVG_SCORE=$( | jq -r )
THRESHOLD=$( | jq -r )
| -a /tmp/claude-hooks.log
EOF
+x .claude/hook-analyzer-v2.sh
.claude/settings.jsonAdd this configuration with automated feedback loop:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "echo '🎯 PRE-EDIT VERIFICATION' | tee -a /tmp/claude-hooks.log && FILE=$(cat | jq -r '.tool_input.file_path // .tool_input.path // empty') && echo \"Target: $FILE\" | tee -a /tmp/claude-hooks.log && echo '⚠️ REQUIREMENTS:' | tee -a /tmp/claude-hooks.log && echo ' • Real implementations only (no mocks in production)' | tee -a /tmp/claude-hooks.log && echo ' • No hardcoded secrets - use environment variables' | tee -a /tmp/claude-hooks.log && echo ' • Complete error handling' | tee -a /tmp/claude-hooks.log && echo ' • Secure protocols (HTTPS)' | tee -a /tmp/claude-hooks.log"
}
]
}
],
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command"
<user-prompt-submit-hook> tagstest: 0.60Overall Average: 0.9 (threshold: 0.85)/tmp/claude-hooks.logtee -a for complete historypassword, secret, token, key, credentialapiKey, API_KEY, authToken, etc.(password|secret|token|key|credential)[[:space:]]*=[[:space:]]*["'][^"']+["']Integrate Claude Flow's verification system for automated truth scoring:
{
"PreToolUse": [{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{
"type": "command",
"command": "echo '🔬 Initializing Claude Flow Verification...' && npx claude-flow@alpha verify init strict 2>/dev/null && echo '✅ Strict mode: 0.95 threshold' || echo '⚠️ Claude Flow not available'"
}]
}],
"PostToolUse": [{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{
"type": "command",
"command": "FILE=$(cat | jq -r '.tool_input.file_path // .tool_input.path // empty') && echo '📊 CLAUDE FLOW VERIFICATION' && npx claude-flow@alpha verify verify \"$FILE\" --agent coder --threshold 0.95 2>/dev/null || echo ' Manual check required' && npx claude-flow@alpha truth --agent coder --json 2>/dev/null | jq -r '\"Truth Score: \\(.averageScore // \"N/A\")\"' || true"
}]
}]
Combine Claude Flow verification with manual scoring:
{
"PostToolUse": [{
"matcher": "Write|Edit|MultiEdit",
"hooks": [{
"type": "command",
"command": "FILE=$(cat | jq -r '.tool_input.file_path // .tool_input.path // empty') && echo '📊 CODE QUALITY ANALYSIS' && echo \"File: $FILE\" && SCORE=100 && grep -q 'TODO' \"$FILE\" 2>/dev/null && { echo ' ❌ TODO found (-15)'; SCORE=$((SCORE-15)); } || echo ' ✓ No TODOs' && grep -q 'console.log' \"$FILE\" 2>/dev/null && { echo ' ⚠️ console.log (-5)'; SCORE=$((SCORE-5)); } || echo ' ✓ No console.log' && grep -qE 'mock|Mock|placeholder' \"$FILE\" 2>/dev/null && { echo ' ❌ Mock detected (-25)'; SCORE=$((SCORE-25)); } || echo ' ✓ No mocks' && echo \"📊 Manual Score: $SCORE/100\" && echo '' && echo '🔬 Claude Flow Truth Analysis:' && npx claude-flow@alpha truth --report --agent coder 2>/dev/null | head -10 || echo ' Claude Flow not available'"
}]
}]
}
Detect potential security issues in commands:
{
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "CMD=$(cat | jq -r '.tool_input.command // empty') && echo \"$CMD\" | grep -qE 'export.*(KEY|TOKEN|SECRET|PASSWORD)' && echo '⚠️ SECURITY WARNING: Potential secret exposure!' || true"
}]
}]
}
🎯 PRE-EDIT VERIFICATION
Target: /workspaces/flow-cloud/test-hooks.js
⚠️ REQUIREMENTS:
• Real implementations only (no mocks in production)
• No hardcoded secrets - use environment variables
• Complete error handling
• Secure protocols (HTTPS)
✅ POST-EDIT ANALYSIS
Modified: /workspaces/flow-cloud/test-hooks.js
Security Check Results:
⚠️ TODO comments found
⚠️ console.log detected
🚨 Hardcoded password!
📊 Claude Flow Verification:
✅ compile: 1.00
❌ test: 0.60
✅ lint: 1.00
📊 Verification Score: 0.90/0.85
Status: ✅ PASSED
Overall Average: 0.9 (threshold: 0.85)
| Benefit | Description |
|---|---|
| Automated Truth Scoring | Reliability metrics with configurable thresholds (0.75-0.95) |
| Pair Programming Mode | Real-time collaborative verification during edits |
| Implementation Verification | Confirms functional requirements are met |
| Continuous Quality Metrics | Track truth scores and trends over time |
The verification commands add quantitative analysis to the qualitative checklist, giving you both human-readable reminders and data-driven confidence scores.
settings.jsonjq '.' .claude/settings.json:* not just */doctor to validate settingschmod +x .claude/hook-analyzer-v2.sh💡 Remember: The goal is real, secure, functional code - not placeholders or simulations. These hooks keep AI agents focused on production-quality implementations.
For advanced verification with Claude Flow:
# Install Claude Flow globally
npm install -g claude-flow@alpha
npx claude-flow@alpha verify init strict # 0.95 threshold
npx claude-flow@alpha truth # View scores
npx claude-flow@alpha verify verify "$FILE" --threshold 0.95
npx claude-flow@alpha verify init strict # 0.95 threshold
npx claude-flow@alpha verify init moderate # 0.85 threshold
npx claude-flow@alpha verify init development # 0.75 threshold
npx claude-flow@alpha verify verify <file> --agent coder --threshold 0.95
npx claude-flow@alpha verify status --recent 10
npx claude-flow@alpha verify rollback --checkpoint last
npx claude-flow@alpha truth # Current scores
npx claude-flow@alpha truth --report # Detailed report
npx claude-flow@alpha truth --analyze # Pattern analysis
npx claude-flow@alpha truth --agent coder # Filter by agent
npx claude-flow@alpha truth --json | jq .averageScore # For hooks
✅ PreToolUse prevents errors before edits happen
✅ PostToolUse enforces checks right after changes
✅ Claude Flow verification provides truth-based enforcement at a 0.95 threshold
✅ Security hooks stop secrets from leaking
✅ Quantitative + qualitative = code that is real, secure, and production-ready
By building these checks into Claude Code, you shift from reactive debugging to proactive verification.