Skip to content

Commit 4c1e562

Browse files
committed
let claude use skill-author skill to improve all
1 parent b70cd6d commit 4c1e562

File tree

88 files changed

+9413
-9417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+9413
-9417
lines changed

barretenberg/cpp/.claude/scripts/run-all-audits.sh

Lines changed: 190 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/bash
22
#
3-
# run-all-audits.sh - Run all vm2-audit-* skills in parallel
3+
# run-all-audits.sh - Run vm2-audit-* skills in parallel with tier selection
44
#
55
# Usage:
66
# ./run-all-audits.sh [OPTIONS]
77
#
88
# Options:
9+
# -T, --tier TIERS Run specific tier(s): 1, 2, 3, 4, or combinations like "1,2" or "1-3"
10+
# Default: all tiers. Examples:
11+
# -T 1 Run Tier 1 (Critical) only
12+
# -T 1,2 Run Tiers 1 and 2
13+
# -T 1-3 Run Tiers 1 through 3
914
# -j, --jobs N Maximum parallel jobs (default: 4)
1015
# -o, --output DIR Output directory (default: ./audit-results)
1116
# -s, --skill SKILL Run only specific skill(s) (can be repeated)
@@ -14,10 +19,23 @@
1419
# --summarize-only Only run summarizer on existing results
1520
# --no-summarize Skip the summarizer step
1621
# --multi-model-summary Run extra multi-model validation (Gemini/GPT via PAL MCP)
22+
# --list-skills List available skills by tier and exit
1723
# -h, --help Show this help message
1824
#
25+
# Tier Descriptions:
26+
# Tier 1 (Critical): Must-run skills that find the most severe bugs
27+
# Tier 2 (High): High-value skills, should run for thorough audits
28+
# Tier 3 (Moderate): Good-to-have skills for comprehensive coverage
29+
# Tier 4 (Sanity): Sanity-check skills, usually return clean results
30+
#
1931
# Environment Variables:
2032
# EXTRA_MULTI_MODEL_SUMMARY=1 Enable multi-model validation (same as --multi-model-summary)
33+
#
34+
# Examples:
35+
# ./run-all-audits.sh -T 1 # Run Tier 1 only (fastest, critical bugs)
36+
# ./run-all-audits.sh -T 1,2 # Run Tiers 1 and 2 (recommended)
37+
# ./run-all-audits.sh -T 1-3 -j 6 # Run Tiers 1-3 with 6 parallel jobs
38+
# ./run-all-audits.sh # Run all tiers (comprehensive)
2139

2240
set -euo pipefail
2341

@@ -26,6 +44,7 @@ RED='\033[0;31m'
2644
GREEN='\033[0;32m'
2745
YELLOW='\033[1;33m'
2846
BLUE='\033[0;34m'
47+
CYAN='\033[0;36m'
2948
NC='\033[0m' # No Color
3049

3150
# Default configuration
@@ -34,30 +53,134 @@ OUTPUT_DIR="./audit-results"
3453
TARGET_PATH="pil/vm2"
3554
MODEL="sonnet"
3655
SPECIFIC_SKILLS=()
56+
SELECTED_TIERS=() # Empty means all tiers
3757
SUMMARIZE_ONLY=false
3858
NO_SUMMARIZE=false
59+
LIST_SKILLS=false
3960
EXTRA_MULTI_MODEL_SUMMARY="${EXTRA_MULTI_MODEL_SUMMARY:-false}"
4061

4162
# Get script directory
4263
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4364
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
4465
SKILLS_DIR="$SCRIPT_DIR/../skills"
4566

46-
# Dynamically discover all vm2-audit-* skills from the skills directory
47-
ALL_SKILLS=()
67+
# Function to parse tier specification
68+
parse_tiers() {
69+
local tier_spec="$1"
70+
local tiers=()
71+
72+
# Handle comma-separated values
73+
IFS=',' read -ra PARTS <<< "$tier_spec"
74+
for part in "${PARTS[@]}"; do
75+
# Handle range (e.g., "1-3" or "0-2")
76+
if [[ "$part" =~ ^([0-4])-([0-4])$ ]]; then
77+
local start="${BASH_REMATCH[1]}"
78+
local end="${BASH_REMATCH[2]}"
79+
for ((i=start; i<=end; i++)); do
80+
tiers+=("$i")
81+
done
82+
# Handle single tier
83+
elif [[ "$part" =~ ^[0-4]$ ]]; then
84+
tiers+=("$part")
85+
else
86+
echo -e "${RED}Invalid tier specification: $part${NC}" >&2
87+
echo "Valid tiers: 0, 1, 2, 3, 4 (or ranges like 0-2, 1-3)" >&2
88+
exit 1
89+
fi
90+
done
91+
92+
# Remove duplicates and sort
93+
printf '%s\n' "${tiers[@]}" | sort -u
94+
}
95+
96+
# Dynamically discover all vm2-audit-* skills from the skills directory, organized by tier
97+
declare -A TIER_SKILLS
98+
TIER_SKILLS[0]=""
99+
TIER_SKILLS[1]=""
100+
TIER_SKILLS[2]=""
101+
TIER_SKILLS[3]=""
102+
TIER_SKILLS[4]=""
103+
OTHER_SKILLS=""
104+
48105
for dir in "$SKILLS_DIR"/vm2-audit-*/; do
49106
if [[ -d "$dir" ]]; then
50107
skill_name=$(basename "$dir")
51-
ALL_SKILLS+=("$skill_name")
108+
# Extract tier from skill name (vm2-audit-t0-*, vm2-audit-t1-*, etc.)
109+
if [[ "$skill_name" =~ ^vm2-audit-t([0-4])- ]]; then
110+
tier="${BASH_REMATCH[1]}"
111+
TIER_SKILLS[$tier]="${TIER_SKILLS[$tier]} $skill_name"
112+
else
113+
OTHER_SKILLS="$OTHER_SKILLS $skill_name"
114+
fi
52115
fi
53116
done
54117

55-
# Sort for consistent ordering
56-
IFS=$'\n' ALL_SKILLS=($(sort <<<"${ALL_SKILLS[*]}")); unset IFS
118+
# Function to list skills by tier
119+
list_skills() {
120+
echo -e "${GREEN}╔══════════════════════════════════════════════════════════════╗${NC}"
121+
echo -e "${GREEN}║ VM2 Audit Skills by Tier ║${NC}"
122+
echo -e "${GREEN}╚══════════════════════════════════════════════════════════════╝${NC}"
123+
echo ""
124+
125+
echo -e "${CYAN}Tier 0 - Opcode Cross-Layer Consistency:${NC}"
126+
for skill in ${TIER_SKILLS[0]}; do
127+
echo " - $skill"
128+
done
129+
echo " Count: $(echo ${TIER_SKILLS[0]} | wc -w)"
130+
echo ""
131+
132+
echo -e "${CYAN}Tier 1 - Critical (Must Have):${NC}"
133+
for skill in ${TIER_SKILLS[1]}; do
134+
echo " - $skill"
135+
done
136+
echo " Count: $(echo ${TIER_SKILLS[1]} | wc -w)"
137+
echo ""
138+
139+
echo -e "${CYAN}Tier 2 - High Value (Should Have):${NC}"
140+
for skill in ${TIER_SKILLS[2]}; do
141+
echo " - $skill"
142+
done
143+
echo " Count: $(echo ${TIER_SKILLS[2]} | wc -w)"
144+
echo ""
145+
146+
echo -e "${CYAN}Tier 3 - Moderate Value (Good to Have):${NC}"
147+
for skill in ${TIER_SKILLS[3]}; do
148+
echo " - $skill"
149+
done
150+
echo " Count: $(echo ${TIER_SKILLS[3]} | wc -w)"
151+
echo ""
152+
153+
echo -e "${CYAN}Tier 4 - Sanity Checks (Optional):${NC}"
154+
for skill in ${TIER_SKILLS[4]}; do
155+
echo " - $skill"
156+
done
157+
echo " Count: $(echo ${TIER_SKILLS[4]} | wc -w)"
158+
echo ""
159+
160+
if [[ -n "$OTHER_SKILLS" ]]; then
161+
echo -e "${YELLOW}Other (non-tiered):${NC}"
162+
for skill in $OTHER_SKILLS; do
163+
echo " - $skill"
164+
done
165+
echo ""
166+
fi
167+
168+
local total=0
169+
for t in 0 1 2 3 4; do
170+
total=$((total + $(echo ${TIER_SKILLS[$t]} | wc -w)))
171+
done
172+
echo -e "${GREEN}Total tiered skills: $total${NC}"
173+
}
57174

58175
# Parse command line arguments
59176
while [[ $# -gt 0 ]]; do
60177
case $1 in
178+
-T|--tier)
179+
while IFS= read -r tier; do
180+
SELECTED_TIERS+=("$tier")
181+
done < <(parse_tiers "$2")
182+
shift 2
183+
;;
61184
-j|--jobs)
62185
MAX_JOBS="$2"
63186
shift 2
@@ -90,8 +213,12 @@ while [[ $# -gt 0 ]]; do
90213
EXTRA_MULTI_MODEL_SUMMARY=true
91214
shift
92215
;;
216+
--list-skills)
217+
LIST_SKILLS=true
218+
shift
219+
;;
93220
-h|--help)
94-
head -20 "$0" | tail -n +2 | sed 's/^# //' | sed 's/^#//'
221+
head -38 "$0" | tail -n +2 | sed 's/^# //' | sed 's/^#//'
95222
exit 0
96223
;;
97224
*)
@@ -101,13 +228,39 @@ while [[ $# -gt 0 ]]; do
101228
esac
102229
done
103230

104-
# Determine which skills to run
231+
# Handle --list-skills
232+
if [[ "$LIST_SKILLS" == "true" ]]; then
233+
list_skills
234+
exit 0
235+
fi
236+
237+
# Build list of skills to run
238+
ALL_SKILLS=()
239+
105240
if [[ ${#SPECIFIC_SKILLS[@]} -gt 0 ]]; then
106-
SKILLS_TO_RUN=("${SPECIFIC_SKILLS[@]}")
241+
# Use specific skills if provided
242+
ALL_SKILLS=("${SPECIFIC_SKILLS[@]}")
243+
elif [[ ${#SELECTED_TIERS[@]} -gt 0 ]]; then
244+
# Use skills from selected tiers
245+
for tier in "${SELECTED_TIERS[@]}"; do
246+
for skill in ${TIER_SKILLS[$tier]}; do
247+
ALL_SKILLS+=("$skill")
248+
done
249+
done
107250
else
108-
SKILLS_TO_RUN=("${ALL_SKILLS[@]}")
251+
# Use all tiered skills
252+
for tier in 0 1 2 3 4; do
253+
for skill in ${TIER_SKILLS[$tier]}; do
254+
ALL_SKILLS+=("$skill")
255+
done
256+
done
109257
fi
110258

259+
# Sort for consistent ordering
260+
IFS=$'\n' ALL_SKILLS=($(sort <<<"${ALL_SKILLS[*]}")); unset IFS
261+
262+
SKILLS_TO_RUN=("${ALL_SKILLS[@]}")
263+
111264
# Create output directory
112265
mkdir -p "$OUTPUT_DIR"
113266

@@ -163,7 +316,7 @@ show_progress() {
163316
case "$status" in
164317
success) ((++completed)) ;;
165318
failed) ((++failed)); ((++completed)) ;;
166-
running) ((++running)); running_skills+=("${skill#vm2-audit-}") ;;
319+
running) ((++running)); running_skills+=("${skill#vm2-audit-t?-}") ;;
167320
esac
168321
fi
169322
done
@@ -229,11 +382,34 @@ else
229382
log " Target path: $TARGET_PATH"
230383
log " Model: $MODEL"
231384
log " Max parallel jobs: $MAX_JOBS"
385+
if [[ ${#SELECTED_TIERS[@]} -gt 0 ]]; then
386+
log " Selected tiers: ${SELECTED_TIERS[*]}"
387+
else
388+
log " Selected tiers: all (1-4)"
389+
fi
232390
log " Skills to run: ${#SKILLS_TO_RUN[@]}"
233391
log ""
234-
log "Skills:"
235-
for skill in "${SKILLS_TO_RUN[@]}"; do
236-
log " - $skill"
392+
393+
# Group skills by tier for display
394+
log "Skills by tier:"
395+
for tier in 0 1 2 3 4; do
396+
tier_count=0
397+
tier_skills=""
398+
for skill in "${SKILLS_TO_RUN[@]}"; do
399+
if [[ "$skill" =~ ^vm2-audit-t${tier}- ]]; then
400+
((++tier_count))
401+
tier_skills="$tier_skills $skill"
402+
fi
403+
done
404+
if [[ $tier_count -gt 0 ]]; then
405+
case $tier in
406+
0) log " ${CYAN}Tier 0 (Opcode):${NC} $tier_count skills" ;;
407+
1) log " ${CYAN}Tier 1 (Critical):${NC} $tier_count skills" ;;
408+
2) log " ${CYAN}Tier 2 (High):${NC} $tier_count skills" ;;
409+
3) log " ${CYAN}Tier 3 (Moderate):${NC} $tier_count skills" ;;
410+
4) log " ${CYAN}Tier 4 (Sanity):${NC} $tier_count skills" ;;
411+
esac
412+
fi
237413
done
238414
log ""
239415
log "${YELLOW}Starting audit runs...${NC}"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
---
3+
4+
## Required Output Format
5+
6+
**IMPORTANT**: When running this audit skill, you MUST end your response with this standardized format.
7+
8+
### Findings Summary
9+
10+
At the end of your audit, provide a summary section:
11+
12+
```markdown
13+
## Audit Results
14+
15+
### Summary
16+
| Item | Value |
17+
|------|-------|
18+
| Skill | {SKILL_NAME} |
19+
| Target | [path that was audited] |
20+
| Files Scanned | [number] |
21+
| Findings | [count by severity, e.g., "2 Critical, 1 High, 0 Medium, 0 Low"] |
22+
| Status | COMPLETED_WITH_FINDINGS / COMPLETED_NO_FINDINGS / ERROR |
23+
24+
### Findings
25+
26+
#### Finding {PREFIX}-[file]-[line]-[subtype] [SEVERITY]
27+
- **File**: `path/to/file.pil:line`
28+
- **Type**: [specific vulnerability type]
29+
- **Affected Column/Constraint**: [name]
30+
- **Description**: [brief description]
31+
- **Exploitability**: [High/Medium/Low] - [brief rationale]
32+
- **Suggested Fix**: [one-line fix suggestion]
33+
34+
[Repeat for each finding]
35+
```
36+
37+
### Machine-Readable Findings
38+
39+
After the human-readable summary, include a JSON block:
40+
41+
```markdown
42+
<!-- MACHINE-READABLE FINDINGS (do not edit manually) -->
43+
```json
44+
{
45+
"skill": "{SKILL_NAME}",
46+
"finding_prefix": "{PREFIX}",
47+
"status": "COMPLETED_WITH_FINDINGS | COMPLETED_NO_FINDINGS | ERROR",
48+
"target": "pil/vm2",
49+
"files_scanned": 0,
50+
"findings": [
51+
{
52+
"id": "{PREFIX}-filename-line-subtype",
53+
"severity": "critical|high|medium|low",
54+
"file": "path/to/file.pil",
55+
"line": 123,
56+
"type": "specific-vulnerability-type",
57+
"column": "affected_column_name",
58+
"description": "Brief description of the issue",
59+
"exploitability": "high|medium|low",
60+
"fix": "Suggested fix"
61+
}
62+
]
63+
}
64+
```
65+
<!-- END MACHINE-READABLE FINDINGS -->
66+
```
67+
68+
### Finding ID Convention
69+
70+
- Format: `{SKILL_NAME}-[filename]-[line]-[subtype]`
71+
- Example: `{SKILL_NAME}-alu-123-SEL`
72+
- Use lowercase for filename (without extension)
73+
- Use CAPS for subtype descriptors
74+
75+
### Status Values
76+
77+
- `COMPLETED_NO_FINDINGS` - Audit completed, no issues found
78+
- `COMPLETED_WITH_FINDINGS` - Audit completed, issues found
79+
- `ERROR` - Audit could not complete (explain in description)

0 commit comments

Comments
 (0)