autoworkflow 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/analyze.md +77 -0
- package/.claude/commands/audit.md +220 -0
- package/.claude/commands/build.md +159 -0
- package/.claude/commands/commit.md +165 -0
- package/.claude/commands/fix.md +119 -0
- package/.claude/commands/plan.md +101 -0
- package/.claude/commands/suggest.md +195 -0
- package/.claude/commands/verify.md +113 -0
- package/.claude/settings.json +129 -0
- package/.claude/settings.local.json +9 -0
- package/.prettierrc +11 -0
- package/.vscode/extensions.json +27 -0
- package/.vscode/settings.json +69 -0
- package/.vscode/tasks.json +161 -0
- package/CLAUDE.md +344 -0
- package/README.md +180 -195
- package/eslint.config.example.js +83 -0
- package/hooks/commit-msg +137 -0
- package/hooks/pre-commit +152 -0
- package/instructions/AI_RULES.md +284 -0
- package/instructions/BLUEPRINT.md +170 -0
- package/instructions/CLAUDE.md +472 -0
- package/package.json +45 -45
- package/scripts/autoworkflow.sh +324 -0
- package/scripts/check-ui-enforcement.sh +177 -0
- package/scripts/ensure-no-errors.sh +116 -0
- package/scripts/run-verification.sh +112 -0
- package/scripts/setup.sh +201 -0
- package/system/gates.md +390 -0
- package/system/loops.md +348 -0
- package/system/router.md +415 -0
- package/system/triggers.md +369 -0
- package/tsconfig.example.json +52 -0
- package/bin/cli.js +0 -299
- package/lib/index.js +0 -9
- package/lib/install.js +0 -600
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# run-verification.sh
|
|
3
|
+
# Runs TypeScript + ESLint verification with structured output
|
|
4
|
+
|
|
5
|
+
set -o pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
9
|
+
|
|
10
|
+
# Colors
|
|
11
|
+
RED='\033[0;31m'
|
|
12
|
+
GREEN='\033[0;32m'
|
|
13
|
+
YELLOW='\033[1;33m'
|
|
14
|
+
NC='\033[0m'
|
|
15
|
+
|
|
16
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
17
|
+
echo "🔍 VERIFICATION PHASE"
|
|
18
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
19
|
+
|
|
20
|
+
cd "$PROJECT_ROOT"
|
|
21
|
+
|
|
22
|
+
ERRORS_FOUND=0
|
|
23
|
+
TS_ERRORS=0
|
|
24
|
+
LINT_ERRORS=0
|
|
25
|
+
|
|
26
|
+
# ─────────────────────────────────────────────────────────────
|
|
27
|
+
# TypeScript Check
|
|
28
|
+
# ─────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
echo ""
|
|
31
|
+
echo "📋 Running TypeScript check..."
|
|
32
|
+
echo ""
|
|
33
|
+
|
|
34
|
+
TSC_OUTPUT=$(npm run typecheck 2>&1) || true
|
|
35
|
+
|
|
36
|
+
if echo "$TSC_OUTPUT" | grep -q "error TS"; then
|
|
37
|
+
TS_ERRORS=$(echo "$TSC_OUTPUT" | grep -c "error TS" || echo "0")
|
|
38
|
+
ERRORS_FOUND=1
|
|
39
|
+
|
|
40
|
+
echo -e "${RED}❌ TypeScript: $TS_ERRORS error(s) found${NC}"
|
|
41
|
+
echo ""
|
|
42
|
+
echo "$TSC_OUTPUT" | grep "error TS" | head -20
|
|
43
|
+
|
|
44
|
+
if [ "$TS_ERRORS" -gt 20 ]; then
|
|
45
|
+
echo ""
|
|
46
|
+
echo "... and $(($TS_ERRORS - 20)) more errors"
|
|
47
|
+
fi
|
|
48
|
+
else
|
|
49
|
+
echo -e "${GREEN}✅ TypeScript: No errors${NC}"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# ─────────────────────────────────────────────────────────────
|
|
53
|
+
# ESLint Check
|
|
54
|
+
# ─────────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
echo ""
|
|
57
|
+
echo "📋 Running ESLint check..."
|
|
58
|
+
echo ""
|
|
59
|
+
|
|
60
|
+
LINT_OUTPUT=$(npm run lint 2>&1) || true
|
|
61
|
+
|
|
62
|
+
if echo "$LINT_OUTPUT" | grep -qE "error|warning"; then
|
|
63
|
+
LINT_ERRORS=$(echo "$LINT_OUTPUT" | grep -cE "error|warning" || echo "0")
|
|
64
|
+
ERRORS_FOUND=1
|
|
65
|
+
|
|
66
|
+
echo -e "${RED}❌ ESLint: Issues found${NC}"
|
|
67
|
+
echo ""
|
|
68
|
+
echo "$LINT_OUTPUT" | head -30
|
|
69
|
+
else
|
|
70
|
+
echo -e "${GREEN}✅ ESLint: No warnings${NC}"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# ─────────────────────────────────────────────────────────────
|
|
74
|
+
# Summary
|
|
75
|
+
# ─────────────────────────────────────────────────────────────
|
|
76
|
+
|
|
77
|
+
echo ""
|
|
78
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
79
|
+
|
|
80
|
+
if [ $ERRORS_FOUND -eq 0 ]; then
|
|
81
|
+
echo -e "${GREEN}✅ VERIFICATION PASSED${NC}"
|
|
82
|
+
echo ""
|
|
83
|
+
echo "No TypeScript errors."
|
|
84
|
+
echo "No ESLint warnings."
|
|
85
|
+
echo ""
|
|
86
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
87
|
+
echo -e "${GREEN}✓ Ready to commit${NC}"
|
|
88
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
89
|
+
|
|
90
|
+
echo ""
|
|
91
|
+
echo "VERIFICATION_STATUS=PASSED"
|
|
92
|
+
echo "TS_ERRORS=0"
|
|
93
|
+
echo "LINT_ERRORS=0"
|
|
94
|
+
|
|
95
|
+
exit 0
|
|
96
|
+
else
|
|
97
|
+
echo -e "${RED}❌ VERIFICATION FAILED${NC}"
|
|
98
|
+
echo ""
|
|
99
|
+
echo "TypeScript errors: $TS_ERRORS"
|
|
100
|
+
echo "ESLint issues: $LINT_ERRORS"
|
|
101
|
+
echo ""
|
|
102
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
103
|
+
echo -e "${YELLOW}⚠️ Fix errors before proceeding${NC}"
|
|
104
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
105
|
+
|
|
106
|
+
echo ""
|
|
107
|
+
echo "VERIFICATION_STATUS=FAILED"
|
|
108
|
+
echo "TS_ERRORS=$TS_ERRORS"
|
|
109
|
+
echo "LINT_ERRORS=$LINT_ERRORS"
|
|
110
|
+
|
|
111
|
+
exit 1
|
|
112
|
+
fi
|
package/scripts/setup.sh
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# setup.sh
|
|
3
|
+
# AutoWorkflow - Full Setup Script
|
|
4
|
+
# This script sets up the complete workflow system for any project
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
CYAN='\033[0;36m'
|
|
14
|
+
NC='\033[0m'
|
|
15
|
+
|
|
16
|
+
print_banner() {
|
|
17
|
+
echo ""
|
|
18
|
+
echo -e "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
|
|
19
|
+
echo -e "${CYAN}║ ║${NC}"
|
|
20
|
+
echo -e "${CYAN}║ AUTOWORKFLOW SETUP ║${NC}"
|
|
21
|
+
echo -e "${CYAN}║ System Prompt Layer for Claude Code ║${NC}"
|
|
22
|
+
echo -e "${CYAN}║ ║${NC}"
|
|
23
|
+
echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}"
|
|
24
|
+
echo ""
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
28
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
29
|
+
TARGET_DIR="${1:-.}"
|
|
30
|
+
|
|
31
|
+
print_banner
|
|
32
|
+
|
|
33
|
+
echo -e "${BLUE}Target directory: $TARGET_DIR${NC}"
|
|
34
|
+
echo ""
|
|
35
|
+
|
|
36
|
+
# Navigate to target
|
|
37
|
+
cd "$TARGET_DIR"
|
|
38
|
+
|
|
39
|
+
# Step 1: Check prerequisites
|
|
40
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
41
|
+
echo "Step 1: Checking prerequisites"
|
|
42
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
43
|
+
|
|
44
|
+
if [ ! -f "package.json" ]; then
|
|
45
|
+
echo -e "${YELLOW}⚠️ No package.json found. Creating minimal one...${NC}"
|
|
46
|
+
echo '{"name": "my-project", "version": "1.0.0", "private": true, "type": "module", "scripts": {}}' > package.json
|
|
47
|
+
fi
|
|
48
|
+
echo -e "${GREEN}✓ package.json exists${NC}"
|
|
49
|
+
|
|
50
|
+
# Step 2: Create directory structure
|
|
51
|
+
echo ""
|
|
52
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
53
|
+
echo "Step 2: Creating directory structure"
|
|
54
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
55
|
+
|
|
56
|
+
mkdir -p .claude/commands scripts hooks src
|
|
57
|
+
echo -e "${GREEN}✓ Created directories${NC}"
|
|
58
|
+
|
|
59
|
+
# Step 3: Copy workflow files if source exists
|
|
60
|
+
echo ""
|
|
61
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
62
|
+
echo "Step 3: Installing workflow files"
|
|
63
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
64
|
+
|
|
65
|
+
# Copy from project root if available
|
|
66
|
+
if [ -f "$PROJECT_ROOT/CLAUDE.md" ]; then
|
|
67
|
+
cp "$PROJECT_ROOT/CLAUDE.md" ./CLAUDE.md 2>/dev/null && echo -e "${GREEN}✓ Installed CLAUDE.md${NC}"
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
if [ -d "$PROJECT_ROOT/system" ]; then
|
|
71
|
+
cp -r "$PROJECT_ROOT/system" ./ 2>/dev/null && echo -e "${GREEN}✓ Installed system/ folder${NC}"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if [ -d "$PROJECT_ROOT/instructions" ]; then
|
|
75
|
+
cp -r "$PROJECT_ROOT/instructions" ./ 2>/dev/null && echo -e "${GREEN}✓ Installed instructions/ folder${NC}"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
if [ -d "$PROJECT_ROOT/.claude" ]; then
|
|
79
|
+
cp -r "$PROJECT_ROOT/.claude/"* ./.claude/ 2>/dev/null && echo -e "${GREEN}✓ Installed .claude/ commands${NC}"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
if [ -d "$PROJECT_ROOT/.vscode" ]; then
|
|
83
|
+
mkdir -p .vscode
|
|
84
|
+
cp -r "$PROJECT_ROOT/.vscode/"* ./.vscode/ 2>/dev/null && echo -e "${GREEN}✓ Installed .vscode/ settings${NC}"
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# Step 4: Install Git hooks
|
|
88
|
+
echo ""
|
|
89
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
90
|
+
echo "Step 4: Installing Git hooks"
|
|
91
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
92
|
+
|
|
93
|
+
# Initialize git if needed
|
|
94
|
+
if [ ! -d ".git" ]; then
|
|
95
|
+
git init
|
|
96
|
+
echo -e "${GREEN}✓ Initialized git repository${NC}"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# Copy hooks
|
|
100
|
+
mkdir -p .git/hooks
|
|
101
|
+
if [ -d "$PROJECT_ROOT/hooks" ]; then
|
|
102
|
+
cp "$PROJECT_ROOT/hooks/"* .git/hooks/ 2>/dev/null
|
|
103
|
+
chmod +x .git/hooks/* 2>/dev/null
|
|
104
|
+
echo -e "${GREEN}✓ Installed pre-commit hook${NC}"
|
|
105
|
+
echo -e "${GREEN}✓ Installed commit-msg hook${NC}"
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
# Step 5: Add npm scripts
|
|
109
|
+
echo ""
|
|
110
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
111
|
+
echo "Step 5: Adding npm scripts"
|
|
112
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
113
|
+
|
|
114
|
+
# Add scripts using Node.js
|
|
115
|
+
node -e "
|
|
116
|
+
const fs = require('fs');
|
|
117
|
+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
118
|
+
pkg.scripts = pkg.scripts || {};
|
|
119
|
+
|
|
120
|
+
// Verification commands
|
|
121
|
+
pkg.scripts['typecheck'] = pkg.scripts['typecheck'] || 'tsc --noEmit';
|
|
122
|
+
pkg.scripts['lint'] = pkg.scripts['lint'] || 'eslint . --max-warnings 0';
|
|
123
|
+
pkg.scripts['lint:fix'] = pkg.scripts['lint:fix'] || 'eslint . --fix';
|
|
124
|
+
pkg.scripts['verify'] = 'npm run typecheck && npm run lint';
|
|
125
|
+
pkg.scripts['verify:full'] = 'npm run verify && npm run test';
|
|
126
|
+
|
|
127
|
+
// Formatting
|
|
128
|
+
pkg.scripts['format'] = pkg.scripts['format'] || 'prettier --write .';
|
|
129
|
+
pkg.scripts['format:check'] = pkg.scripts['format:check'] || 'prettier --check .';
|
|
130
|
+
|
|
131
|
+
// Audit commands
|
|
132
|
+
pkg.scripts['audit:ui'] = './scripts/check-ui-enforcement.sh';
|
|
133
|
+
pkg.scripts['audit:cycles'] = 'npx madge --circular --extensions ts,tsx src/ 2>/dev/null || echo \"No circular dependencies found\"';
|
|
134
|
+
pkg.scripts['audit:all'] = 'npm run audit:ui && npm run audit:cycles';
|
|
135
|
+
|
|
136
|
+
// Workflow commands
|
|
137
|
+
pkg.scripts['dyad:status'] = './scripts/autoworkflow.sh status';
|
|
138
|
+
pkg.scripts['dyad:verify'] = './scripts/autoworkflow.sh verify';
|
|
139
|
+
pkg.scripts['dyad:commit'] = './scripts/autoworkflow.sh commit';
|
|
140
|
+
pkg.scripts['dyad:full'] = './scripts/autoworkflow.sh full';
|
|
141
|
+
|
|
142
|
+
// Hook setup
|
|
143
|
+
pkg.scripts['setup:hooks'] = 'cp hooks/* .git/hooks/ 2>/dev/null && chmod +x .git/hooks/* 2>/dev/null || true';
|
|
144
|
+
pkg.scripts['postinstall'] = 'npm run setup:hooks 2>/dev/null || true';
|
|
145
|
+
|
|
146
|
+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
|
|
147
|
+
" 2>/dev/null && echo -e "${GREEN}✓ Added npm scripts${NC}" || echo -e "${YELLOW}⚠️ Could not auto-update package.json${NC}"
|
|
148
|
+
|
|
149
|
+
# Step 6: Copy scripts
|
|
150
|
+
echo ""
|
|
151
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
152
|
+
echo "Step 6: Installing automation scripts"
|
|
153
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
154
|
+
|
|
155
|
+
if [ -d "$PROJECT_ROOT/scripts" ]; then
|
|
156
|
+
cp "$PROJECT_ROOT/scripts/"*.sh ./scripts/ 2>/dev/null
|
|
157
|
+
chmod +x ./scripts/*.sh 2>/dev/null
|
|
158
|
+
echo -e "${GREEN}✓ Installed automation scripts${NC}"
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# Step 7: Final verification
|
|
162
|
+
echo ""
|
|
163
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
164
|
+
echo "Step 7: Verifying installation"
|
|
165
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
166
|
+
|
|
167
|
+
echo "Checking installed files:"
|
|
168
|
+
[ -f "CLAUDE.md" ] && echo -e " ${GREEN}✓${NC} CLAUDE.md" || echo -e " ${YELLOW}○${NC} CLAUDE.md (optional)"
|
|
169
|
+
[ -d "system" ] && echo -e " ${GREEN}✓${NC} system/" || echo -e " ${YELLOW}○${NC} system/ (optional)"
|
|
170
|
+
[ -d "instructions" ] && echo -e " ${GREEN}✓${NC} instructions/" || echo -e " ${YELLOW}○${NC} instructions/ (optional)"
|
|
171
|
+
[ -d ".claude/commands" ] && echo -e " ${GREEN}✓${NC} .claude/commands/" || echo -e " ${YELLOW}○${NC} .claude/commands/"
|
|
172
|
+
[ -f ".git/hooks/pre-commit" ] && echo -e " ${GREEN}✓${NC} pre-commit hook" || echo -e " ${YELLOW}○${NC} pre-commit hook"
|
|
173
|
+
[ -f ".git/hooks/commit-msg" ] && echo -e " ${GREEN}✓${NC} commit-msg hook" || echo -e " ${YELLOW}○${NC} commit-msg hook"
|
|
174
|
+
[ -d "scripts" ] && echo -e " ${GREEN}✓${NC} scripts/" || echo -e " ${YELLOW}○${NC} scripts/"
|
|
175
|
+
|
|
176
|
+
echo ""
|
|
177
|
+
echo -e "${GREEN}╔══════════════════════════════════════════════════════════════╗${NC}"
|
|
178
|
+
echo -e "${GREEN}║ ║${NC}"
|
|
179
|
+
echo -e "${GREEN}║ ✅ SETUP COMPLETE ║${NC}"
|
|
180
|
+
echo -e "${GREEN}║ ║${NC}"
|
|
181
|
+
echo -e "${GREEN}╚══════════════════════════════════════════════════════════════╝${NC}"
|
|
182
|
+
echo ""
|
|
183
|
+
echo "Next steps:"
|
|
184
|
+
echo ""
|
|
185
|
+
echo " 1. Install dependencies:"
|
|
186
|
+
echo " ${CYAN}npm install${NC}"
|
|
187
|
+
echo ""
|
|
188
|
+
echo " 2. Start developing with Claude Code:"
|
|
189
|
+
echo " ${CYAN}code .${NC}"
|
|
190
|
+
echo ""
|
|
191
|
+
echo " 3. Claude will automatically:"
|
|
192
|
+
echo " • Follow the workflow in CLAUDE.md"
|
|
193
|
+
echo " • Verify after every change"
|
|
194
|
+
echo " • Fix errors before committing"
|
|
195
|
+
echo " • Enforce UI completeness"
|
|
196
|
+
echo ""
|
|
197
|
+
echo "Available commands:"
|
|
198
|
+
echo " ${CYAN}npm run verify${NC} - TypeScript + ESLint check"
|
|
199
|
+
echo " ${CYAN}npm run audit:all${NC} - UI enforcement + circular deps"
|
|
200
|
+
echo " ${CYAN}npm run dyad:full${NC} - Full workflow"
|
|
201
|
+
echo ""
|
package/system/gates.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# System Gates
|
|
2
|
+
|
|
3
|
+
> Blocking checkpoints that MUST pass before proceeding.
|
|
4
|
+
> Gates enforce hard rules that cannot be bypassed.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Gate Philosophy
|
|
9
|
+
|
|
10
|
+
Gates are **BLOCKING**. If a gate fails:
|
|
11
|
+
1. Claude MUST stop
|
|
12
|
+
2. Claude MUST report the failure
|
|
13
|
+
3. Claude MUST NOT proceed until resolved
|
|
14
|
+
4. User CANNOT override blocking gates (only fix the issue)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Gate Definitions
|
|
19
|
+
|
|
20
|
+
### `analyze_gate`
|
|
21
|
+
|
|
22
|
+
**Phase:** Before ANALYZE → PLAN transition
|
|
23
|
+
**Purpose:** Ensure adequate analysis was performed
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
GATE: analyze_gate
|
|
27
|
+
├── REQUIRES:
|
|
28
|
+
│ ✓ Read relevant source files
|
|
29
|
+
│ ✓ Understood existing code patterns
|
|
30
|
+
│ ✓ Identified affected files
|
|
31
|
+
│ ✓ Checked BLUEPRINT.md for requirements
|
|
32
|
+
│ ✓ Checked AI_RULES.md for standards
|
|
33
|
+
│
|
|
34
|
+
├── ON_PASS:
|
|
35
|
+
│ └── Proceed to: PLAN phase
|
|
36
|
+
│
|
|
37
|
+
└── ON_FAIL:
|
|
38
|
+
└── BLOCK: "Insufficient analysis"
|
|
39
|
+
└── Report: what's missing
|
|
40
|
+
└── Return to: ANALYZE phase
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### `plan_approval_gate`
|
|
46
|
+
|
|
47
|
+
**Phase:** Before PLAN → IMPLEMENT transition
|
|
48
|
+
**Purpose:** User must approve the plan before implementation
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
GATE: plan_approval_gate
|
|
52
|
+
├── REQUIRES:
|
|
53
|
+
│ ✓ Plan has been presented to user
|
|
54
|
+
│ ✓ Suggestions (if applicable) have been shown
|
|
55
|
+
│ ✓ User has explicitly approved
|
|
56
|
+
│ - "yes", "proceed", "go ahead", "approved", etc.
|
|
57
|
+
│ - OR selected which suggestions to include
|
|
58
|
+
│
|
|
59
|
+
├── ON_PASS:
|
|
60
|
+
│ └── Record: approved suggestions
|
|
61
|
+
│ └── Proceed to: IMPLEMENT phase
|
|
62
|
+
│
|
|
63
|
+
├── ON_FAIL (no approval):
|
|
64
|
+
│ └── BLOCK: "Awaiting user approval"
|
|
65
|
+
│ └── State: "Should I proceed with this plan?"
|
|
66
|
+
│ └── Wait for: user response
|
|
67
|
+
│
|
|
68
|
+
└── ON_REJECT (user says no):
|
|
69
|
+
└── Ask: "What should I change?"
|
|
70
|
+
└── Return to: PLAN phase
|
|
71
|
+
└── Revise: based on feedback
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Approval Detection:**
|
|
75
|
+
```
|
|
76
|
+
APPROVED if user says:
|
|
77
|
+
- "yes" / "y" / "yeah" / "yep"
|
|
78
|
+
- "proceed" / "go ahead" / "do it"
|
|
79
|
+
- "approved" / "lgtm" / "looks good"
|
|
80
|
+
- "all" / "include all" (for suggestions)
|
|
81
|
+
- "required" / "required only"
|
|
82
|
+
- Specific numbers: "1, 3, 5" (for suggestions)
|
|
83
|
+
|
|
84
|
+
NOT APPROVED if user says:
|
|
85
|
+
- "no" / "n" / "nope"
|
|
86
|
+
- "wait" / "hold on"
|
|
87
|
+
- "change" / "modify"
|
|
88
|
+
- Question asking for clarification
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `verify_gate`
|
|
94
|
+
|
|
95
|
+
**Phase:** After IMPLEMENT, before AUDIT/COMMIT
|
|
96
|
+
**Purpose:** Code must pass TypeScript and ESLint checks
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
GATE: verify_gate
|
|
100
|
+
├── REQUIRES:
|
|
101
|
+
│ ✓ npm run typecheck → exit code 0
|
|
102
|
+
│ ✓ npm run lint → exit code 0 (0 warnings)
|
|
103
|
+
│ ✓ No TypeScript errors in any file
|
|
104
|
+
│ ✓ No ESLint errors or warnings
|
|
105
|
+
│
|
|
106
|
+
├── COMMANDS:
|
|
107
|
+
│ npm run verify
|
|
108
|
+
│ (which runs: npm run typecheck && npm run lint)
|
|
109
|
+
│
|
|
110
|
+
├── ON_PASS:
|
|
111
|
+
│ └── Report: "✅ Verification passed"
|
|
112
|
+
│ └── Proceed to: AUDIT phase (if feature) or COMMIT gate
|
|
113
|
+
│
|
|
114
|
+
└── ON_FAIL:
|
|
115
|
+
└── BLOCK: "⛔ Verification failed"
|
|
116
|
+
└── Report: all errors with file:line
|
|
117
|
+
└── Enter: fix_loop (from system/loops.md)
|
|
118
|
+
└── After fix: re-check gate
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Output Format:**
|
|
122
|
+
```
|
|
123
|
+
## Verify Gate Check
|
|
124
|
+
|
|
125
|
+
| Check | Status | Details |
|
|
126
|
+
|-------|--------|---------|
|
|
127
|
+
| TypeScript | ✅/⛔ | X errors found |
|
|
128
|
+
| ESLint | ✅/⛔ | X warnings found |
|
|
129
|
+
|
|
130
|
+
Gate Status: ✅ PASSED / ⛔ BLOCKED
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### `audit_gate`
|
|
136
|
+
|
|
137
|
+
**Phase:** After VERIFY, before COMMIT (for features)
|
|
138
|
+
**Purpose:** No orphan features, no circular dependencies
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
GATE: audit_gate
|
|
142
|
+
├── REQUIRES:
|
|
143
|
+
│ ✓ npm run audit:ui → no orphan features
|
|
144
|
+
│ ✓ npm run audit:cycles → no circular dependencies
|
|
145
|
+
│
|
|
146
|
+
├── CHECKS:
|
|
147
|
+
│ 1. UI Enforcement:
|
|
148
|
+
│ - Every API endpoint has a UI that calls it
|
|
149
|
+
│ - Every hook is used by a component
|
|
150
|
+
│ - Every utility is imported somewhere
|
|
151
|
+
│ - User can access every feature
|
|
152
|
+
│
|
|
153
|
+
│ 2. Circular Dependencies:
|
|
154
|
+
│ - No A → B → A import cycles
|
|
155
|
+
│ - No longer chains (A → B → C → A)
|
|
156
|
+
│
|
|
157
|
+
├── ON_PASS:
|
|
158
|
+
│ └── Report: "✅ All audits passed"
|
|
159
|
+
│ └── Proceed to: pre_commit_gate
|
|
160
|
+
│
|
|
161
|
+
├── ON_UI_FAIL:
|
|
162
|
+
│ └── BLOCK: "⛔ Orphan feature detected"
|
|
163
|
+
│ └── Report: features missing UI
|
|
164
|
+
│ └── Enter: ui_fix_loop
|
|
165
|
+
│ └── After fix: re-check gate
|
|
166
|
+
│
|
|
167
|
+
└── ON_CYCLE_FAIL:
|
|
168
|
+
└── BLOCK: "⛔ Circular dependency detected"
|
|
169
|
+
└── Report: cycle paths
|
|
170
|
+
└── Enter: cycle_fix_loop
|
|
171
|
+
└── After fix: re-check gate
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### `pre_commit_gate`
|
|
177
|
+
|
|
178
|
+
**Phase:** Before COMMIT
|
|
179
|
+
**Purpose:** Final check before committing - ALL rules enforced
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
GATE: pre_commit_gate
|
|
183
|
+
├── REQUIRES:
|
|
184
|
+
│ ✓ verify_gate passed (TypeScript + ESLint clean)
|
|
185
|
+
│ ✓ audit_gate passed (no orphans, no cycles)
|
|
186
|
+
│ ✓ No TODO comments in changed files
|
|
187
|
+
│ ✓ No FIXME comments in changed files
|
|
188
|
+
│ ✓ No console.log in changed files
|
|
189
|
+
│ ✓ No console.debug in changed files
|
|
190
|
+
│ ✓ No console.info in changed files
|
|
191
|
+
│ ✓ Commit message follows conventional format
|
|
192
|
+
│
|
|
193
|
+
├── CHECKS:
|
|
194
|
+
│ 1. Re-verify: npm run verify
|
|
195
|
+
│ 2. Check diff: grep -E "TODO|FIXME"
|
|
196
|
+
│ 3. Check diff: grep "console\.(log|debug|info)"
|
|
197
|
+
│ 4. Validate: commit message format
|
|
198
|
+
│
|
|
199
|
+
├── COMMIT_MESSAGE_FORMAT:
|
|
200
|
+
│ type(scope): description
|
|
201
|
+
│
|
|
202
|
+
│ Valid types: feat, fix, docs, style, refactor,
|
|
203
|
+
│ perf, test, build, ci, chore, revert
|
|
204
|
+
│
|
|
205
|
+
│ Examples:
|
|
206
|
+
│ - feat(auth): add login page
|
|
207
|
+
│ - fix(api): handle null response
|
|
208
|
+
│ - refactor(utils): extract date helpers
|
|
209
|
+
│
|
|
210
|
+
├── ON_PASS:
|
|
211
|
+
│ └── Report: "✅ All pre-commit checks passed"
|
|
212
|
+
│ └── Show: commit preview (files + message)
|
|
213
|
+
│ └── Ask: "Should I commit?"
|
|
214
|
+
│ └── Wait for: user confirmation
|
|
215
|
+
│
|
|
216
|
+
└── ON_FAIL:
|
|
217
|
+
└── BLOCK: "⛔ Cannot commit"
|
|
218
|
+
└── Report: ALL blocking issues
|
|
219
|
+
└── Route to: appropriate fix action
|
|
220
|
+
└── After fix: re-check gate
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Output Format:**
|
|
224
|
+
```
|
|
225
|
+
## Pre-Commit Gate Check
|
|
226
|
+
|
|
227
|
+
| Check | Status | Details |
|
|
228
|
+
|-------|--------|---------|
|
|
229
|
+
| TypeScript | ✅ | No errors |
|
|
230
|
+
| ESLint | ✅ | No warnings |
|
|
231
|
+
| UI Enforcement | ✅ | All features have UI |
|
|
232
|
+
| Circular Deps | ✅ | No cycles |
|
|
233
|
+
| TODO/FIXME | ✅ | None in diff |
|
|
234
|
+
| console.log | ✅ | None in diff |
|
|
235
|
+
| Commit Message | ✅ | Valid format |
|
|
236
|
+
|
|
237
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
238
|
+
✅ ALL GATES PASSED
|
|
239
|
+
|
|
240
|
+
Ready to commit:
|
|
241
|
+
- 3 files changed
|
|
242
|
+
- Message: "feat(auth): add login page"
|
|
243
|
+
|
|
244
|
+
Should I proceed with this commit?
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### `destructive_action_gate`
|
|
250
|
+
|
|
251
|
+
**Phase:** Before any destructive action
|
|
252
|
+
**Purpose:** User must confirm dangerous operations
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
GATE: destructive_action_gate
|
|
256
|
+
├── TRIGGERS_ON:
|
|
257
|
+
│ - Deleting files
|
|
258
|
+
│ - Removing significant code (>50 lines)
|
|
259
|
+
│ - Changing database schema
|
|
260
|
+
│ - Modifying authentication logic
|
|
261
|
+
│ - Changing API contracts
|
|
262
|
+
│ - Force operations (git push --force, etc.)
|
|
263
|
+
│
|
|
264
|
+
├── REQUIRES:
|
|
265
|
+
│ ✓ User explicitly confirms the action
|
|
266
|
+
│ ✓ Impact has been clearly explained
|
|
267
|
+
│
|
|
268
|
+
├── FORMAT:
|
|
269
|
+
│ ⚠️ **Warning:** This will [describe impact].
|
|
270
|
+
│
|
|
271
|
+
│ Files affected:
|
|
272
|
+
│ - [file1]
|
|
273
|
+
│ - [file2]
|
|
274
|
+
│
|
|
275
|
+
│ This action [is/is not] reversible.
|
|
276
|
+
│
|
|
277
|
+
│ **Should I proceed?**
|
|
278
|
+
│
|
|
279
|
+
└── ON_CONFIRM:
|
|
280
|
+
└── Proceed with: action
|
|
281
|
+
└── On reject: cancel action
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Gate Hierarchy
|
|
287
|
+
|
|
288
|
+
Gates are checked in order. Later gates assume earlier gates passed.
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
1. analyze_gate
|
|
292
|
+
│
|
|
293
|
+
▼
|
|
294
|
+
2. plan_approval_gate
|
|
295
|
+
│
|
|
296
|
+
▼
|
|
297
|
+
3. [IMPLEMENT]
|
|
298
|
+
│
|
|
299
|
+
▼
|
|
300
|
+
4. verify_gate
|
|
301
|
+
│
|
|
302
|
+
▼
|
|
303
|
+
5. audit_gate (if feature/component)
|
|
304
|
+
│
|
|
305
|
+
▼
|
|
306
|
+
6. pre_commit_gate
|
|
307
|
+
│
|
|
308
|
+
▼
|
|
309
|
+
7. [COMMIT]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Gate Override Policy
|
|
315
|
+
|
|
316
|
+
**CANNOT be overridden by user:**
|
|
317
|
+
- `verify_gate` - TypeScript/ESLint errors
|
|
318
|
+
- `audit_gate` - Orphan features
|
|
319
|
+
- `pre_commit_gate` - Blocking rule violations
|
|
320
|
+
|
|
321
|
+
**CAN be acknowledged by user:**
|
|
322
|
+
- `destructive_action_gate` - With explicit "yes, delete it"
|
|
323
|
+
|
|
324
|
+
**User controls:**
|
|
325
|
+
- `plan_approval_gate` - User decides when to proceed
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Reporting Gate Status
|
|
330
|
+
|
|
331
|
+
Claude MUST show gate status at phase transitions:
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
## Gate: pre_commit_gate
|
|
335
|
+
|
|
336
|
+
Checking requirements...
|
|
337
|
+
|
|
338
|
+
[1/7] TypeScript errors: ✅ PASS (0 errors)
|
|
339
|
+
[2/7] ESLint warnings: ✅ PASS (0 warnings)
|
|
340
|
+
[3/7] UI Enforcement: ✅ PASS (no orphans)
|
|
341
|
+
[4/7] Circular deps: ✅ PASS (no cycles)
|
|
342
|
+
[5/7] TODO/FIXME: ✅ PASS (none found)
|
|
343
|
+
[6/7] console.log: ✅ PASS (none found)
|
|
344
|
+
[7/7] Commit format: ✅ PASS (valid)
|
|
345
|
+
|
|
346
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
347
|
+
✅ GATE PASSED - Ready to proceed
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Or on failure:
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
## Gate: pre_commit_gate
|
|
354
|
+
|
|
355
|
+
Checking requirements...
|
|
356
|
+
|
|
357
|
+
[1/7] TypeScript errors: ✅ PASS
|
|
358
|
+
[2/7] ESLint warnings: ✅ PASS
|
|
359
|
+
[3/7] UI Enforcement: ⛔ FAIL
|
|
360
|
+
└── Missing UI for: /api/users endpoint
|
|
361
|
+
[4/7] Circular deps: ✅ PASS
|
|
362
|
+
[5/7] TODO/FIXME: ⛔ FAIL
|
|
363
|
+
└── Found: src/utils.ts:42 "TODO: implement"
|
|
364
|
+
[6/7] console.log: ✅ PASS
|
|
365
|
+
[7/7] Commit format: ✅ PASS
|
|
366
|
+
|
|
367
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
368
|
+
⛔ GATE BLOCKED - Cannot proceed
|
|
369
|
+
|
|
370
|
+
Issues to resolve:
|
|
371
|
+
1. Add UI component for /api/users
|
|
372
|
+
2. Remove TODO comment at src/utils.ts:42
|
|
373
|
+
|
|
374
|
+
Fixing now...
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Quick Reference
|
|
380
|
+
|
|
381
|
+
| Gate | When | Blocking Rule |
|
|
382
|
+
|------|------|---------------|
|
|
383
|
+
| `analyze_gate` | Before planning | Must read relevant files |
|
|
384
|
+
| `plan_approval_gate` | Before implementing | User must approve |
|
|
385
|
+
| `verify_gate` | After implementing | Zero TS/ESLint errors |
|
|
386
|
+
| `audit_gate` | Before committing features | No orphans, no cycles |
|
|
387
|
+
| `pre_commit_gate` | Before any commit | All rules enforced |
|
|
388
|
+
| `destructive_action_gate` | Before dangerous ops | User must confirm |
|
|
389
|
+
|
|
390
|
+
**Gates are non-negotiable. Fix issues, don't bypass gates.**
|