Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .claude/agents/codebase-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,50 @@ Testing strategies:
- All tests pass
```

## Self-Review Protocol

Before presenting work, perform a self-review by switching perspective to act as a reviewer:

### Self-Review Checklist

1. **Edge Cases Considered?**
- Null/empty inputs
- Boundary conditions
- Error states

2. **Security Issues Addressed?**
- Input validation at boundaries
- Sanitization applied
- No hardcoded secrets

3. **Error Handling Complete?**
- Exceptions caught appropriately
- User-friendly error messages
- Rollback on failure

4. **Assumptions Clearly Stated?**
- Document non-obvious decisions
- Note limitations

### Self-Review Process

```text
1. Complete implementation
2. Switch perspective: "As a reviewer, what would I flag?"
3. Check each item in checklist above
4. Fix any issues found
5. If significant fix made, note: "Self-review: Fixed [issue]"
6. Maximum 2 self-review iterations to prevent infinite loops
```

### Example Self-Review Note

```markdown
Self-review: Fixed edge case for null input in validate_slug()
- Original code would throw NullPointerException
- Added early return for null/empty values
```

## Error Handling

When errors occur:
Expand Down
30 changes: 30 additions & 0 deletions .github/scripts/auto-fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Auto-fix script for Autonomous Quality Enforcement (AQE) pattern
# This script automatically fixes common issues

set -e

echo "=== Running AQE Auto-Fix ==="

# Fix markdown linting issues
if command -v markdownlint &> /dev/null; then
echo "Running markdownlint --fix..."
markdownlint docs/**/*.md README.md CLAUDE.md CONTRIBUTING.md --fix 2>/dev/null || true
echo "✅ Markdown auto-fix complete"
else
echo "⚠️ markdownlint not installed, skipping markdown fixes"
fi

# Fix trailing whitespace
echo "Removing trailing whitespace..."
find docs -name "*.md" -exec sed -i 's/[[:space:]]*$//' {} \; 2>/dev/null || true
echo "✅ Trailing whitespace removed"

# Ensure files end with newline
echo "Ensuring files end with newline..."
find docs -name "*.md" -exec sh -c 'tail -c1 "$1" | read -r _ || echo >> "$1"' _ {} \; 2>/dev/null || true
echo "✅ Newlines added"

echo ""
echo "=== AQE Auto-Fix Complete ✅ ==="
echo "Run check.sh to verify all issues are resolved"
41 changes: 41 additions & 0 deletions .github/scripts/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# Validation script for Autonomous Quality Enforcement (AQE) pattern
# This script runs all quality checks and returns non-zero on failure

set -e

echo "=== Running AQE Validation Checks ==="

# Check if markdownlint is available
if command -v markdownlint &> /dev/null; then
echo "Running markdownlint..."
markdownlint docs/**/*.md README.md CLAUDE.md CONTRIBUTING.md 2>/dev/null || {
echo "❌ Markdown linting failed"
exit 1
}
echo "✅ Markdown linting passed"
else
echo "⚠️ markdownlint not installed, skipping markdown checks"
fi

# Validate documentation structure
echo "Checking documentation structure..."
test -d docs/patterns || { echo "❌ docs/patterns/ missing"; exit 1; }
test -f docs/README.md || { echo "❌ docs/README.md missing"; exit 1; }
test -d docs/adr || { echo "❌ docs/adr/ missing"; exit 1; }
echo "✅ Documentation structure valid"

# Check for required CLAUDE.md
test -f CLAUDE.md || { echo "❌ CLAUDE.md missing"; exit 1; }
echo "✅ CLAUDE.md exists"

# Check for required agent configuration
test -f .claude/agents/codebase-agent.md || { echo "❌ .claude/agents/codebase-agent.md missing"; exit 1; }
echo "✅ Codebase agent configuration exists"

# Check for context files
test -d .claude/context || { echo "❌ .claude/context/ missing"; exit 1; }
echo "✅ Context directory exists"

echo ""
echo "=== All AQE Validation Checks Passed ✅ ==="
62 changes: 62 additions & 0 deletions .github/scripts/e2e-tests/run-all-e2e-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# Run all E2E pattern tests and report results

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FAILED=0
PASSED=0
RESULTS=""

echo "=========================================="
echo " Pattern Validation E2E Test Suite"
echo "=========================================="
echo ""

run_test() {
local test_name=$1
local test_script=$2

echo "Running: $test_name"
echo "---"

if bash "$SCRIPT_DIR/$test_script"; then
PASSED=$((PASSED + 1))
RESULTS="$RESULTS\n✅ $test_name"
else
FAILED=$((FAILED + 1))
RESULTS="$RESULTS\n❌ $test_name"
fi
echo ""
}

# Run all pattern tests
run_test "Pattern 1: AQE" "test-pattern-1-aqe.sh"
run_test "Pattern 2: CBA" "test-pattern-2-cba.sh"
run_test "Pattern 3: Dependabot" "test-pattern-3-dependabot.sh"
run_test "Pattern 4: GHA" "test-pattern-4-gha.sh"
run_test "Pattern 5: Issue-to-PR" "test-pattern-5-issue-to-pr.sh"
run_test "Pattern 6: Multi-Agent" "test-pattern-6-multi-agent.sh"
run_test "Pattern 7: PR Review" "test-pattern-7-pr-review.sh"
run_test "Pattern 8: Security" "test-pattern-8-security.sh"
run_test "Pattern 9: Self-Review" "test-pattern-9-self-review.sh"
run_test "Pattern 10: Stale" "test-pattern-10-stale.sh"
run_test "Pattern 11: Testing" "test-pattern-11-testing.sh"

# Summary
echo "=========================================="
echo " Test Results Summary"
echo "=========================================="
echo -e "$RESULTS"
echo ""
echo "Passed: $PASSED / $((PASSED + FAILED))"
echo "Failed: $FAILED / $((PASSED + FAILED))"
echo ""

if [[ $FAILED -gt 0 ]]; then
echo "❌ SOME TESTS FAILED"
exit 1
else
echo "✅ ALL TESTS PASSED"
exit 0
fi
55 changes: 55 additions & 0 deletions .github/scripts/e2e-tests/test-pattern-1-aqe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# E2E Test: Pattern 1 - Autonomous Quality Enforcement (AQE)
# Tests that check.sh and auto-fix.sh work correctly

set -e

echo "=== E2E Test: Pattern 1 - AQE ==="

# Test 1: Verify check.sh exists and is executable
echo "Test 1: Verify check.sh exists..."
if [[ -x ".github/scripts/check.sh" ]]; then
echo "✅ check.sh exists and is executable"
else
echo "❌ check.sh missing or not executable"
exit 1
fi

# Test 2: Verify auto-fix.sh exists and is executable
echo "Test 2: Verify auto-fix.sh exists..."
if [[ -x ".github/scripts/auto-fix.sh" ]]; then
echo "✅ auto-fix.sh exists and is executable"
else
echo "❌ auto-fix.sh missing or not executable"
exit 1
fi

# Test 3: Verify validate.yml workflow exists
echo "Test 3: Verify validate.yml workflow exists..."
if [[ -f ".github/workflows/validate.yml" ]]; then
echo "✅ validate.yml workflow exists"
else
echo "❌ validate.yml workflow missing"
exit 1
fi

# Test 4: Run check.sh and verify it executes
echo "Test 4: Run check.sh..."
if .github/scripts/check.sh; then
echo "✅ check.sh executed successfully"
else
echo "❌ check.sh failed"
exit 1
fi

# Test 5: Verify CLAUDE.md has AQE process rule
echo "Test 5: Verify AQE process rule in CLAUDE.md..."
if grep -q "Autonomous Quality Enforcement" CLAUDE.md; then
echo "✅ AQE process rule found in CLAUDE.md"
else
echo "❌ AQE process rule missing from CLAUDE.md"
exit 1
fi

echo ""
echo "=== Pattern 1 (AQE): ALL TESTS PASSED ✅ ==="
66 changes: 66 additions & 0 deletions .github/scripts/e2e-tests/test-pattern-10-stale.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
# E2E Test: Pattern 10 - Stale Issue Management
# Tests that stale workflow is properly configured

set -e

echo "=== E2E Test: Pattern 10 - Stale Issue Management ==="

WORKFLOW=".github/workflows/stale.yml"

# Test 1: Verify workflow exists
echo "Test 1: Verify stale.yml exists..."
if [[ -f "$WORKFLOW" ]]; then
echo "✅ stale.yml exists"
else
echo "❌ stale.yml missing"
exit 1
fi

# Test 2: Verify uses actions/stale
echo "Test 2: Verify uses actions/stale..."
if grep -q "actions/stale" "$WORKFLOW"; then
echo "✅ Uses actions/stale"
else
echo "❌ Does not use actions/stale"
exit 1
fi

# Test 3: Verify schedule trigger configured
echo "Test 3: Verify schedule trigger..."
if grep -q "schedule" "$WORKFLOW"; then
echo "✅ Schedule trigger configured"
else
echo "❌ Schedule trigger not configured"
exit 1
fi

# Test 4: Verify days-before-stale configured
echo "Test 4: Verify stale timing configured..."
if grep -q "days-before-stale" "$WORKFLOW"; then
echo "✅ Stale timing configured"
else
echo "❌ Stale timing not configured"
exit 1
fi

# Test 5: Verify exempt labels configured
echo "Test 5: Verify exempt labels..."
if grep -q "exempt" "$WORKFLOW"; then
echo "✅ Exempt labels configured"
else
echo "❌ Exempt labels not configured"
exit 1
fi

# Test 6: Verify stale message configured
echo "Test 6: Verify stale message..."
if grep -q "stale-issue-message\|stale-pr-message" "$WORKFLOW"; then
echo "✅ Stale message configured"
else
echo "❌ Stale message not configured"
exit 1
fi

echo ""
echo "=== Pattern 10 (Stale): ALL TESTS PASSED ✅ ==="
73 changes: 73 additions & 0 deletions .github/scripts/e2e-tests/test-pattern-11-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
# E2E Test: Pattern 11 - Testing Patterns
# Tests that test pyramid structure exists and tests pass

set -e

echo "=== E2E Test: Pattern 11 - Testing Patterns ==="

# Test 1: Verify tests directory exists
echo "Test 1: Verify tests directory exists..."
if [[ -d "tests" ]]; then
echo "✅ tests directory exists"
else
echo "❌ tests directory missing"
exit 1
fi

# Test 2: Verify unit tests directory exists
echo "Test 2: Verify unit tests directory..."
if [[ -d "tests/unit" ]]; then
echo "✅ tests/unit exists"
else
echo "❌ tests/unit missing"
exit 1
fi

# Test 3: Verify integration tests directory exists
echo "Test 3: Verify integration tests directory..."
if [[ -d "tests/integration" ]]; then
echo "✅ tests/integration exists"
else
echo "❌ tests/integration missing"
exit 1
fi

# Test 4: Verify e2e tests directory exists
echo "Test 4: Verify e2e tests directory..."
if [[ -d "tests/e2e" ]]; then
echo "✅ tests/e2e exists"
else
echo "❌ tests/e2e missing"
exit 1
fi

# Test 5: Verify pytest.ini exists
echo "Test 5: Verify pytest.ini exists..."
if [[ -f "pytest.ini" ]]; then
echo "✅ pytest.ini exists"
else
echo "❌ pytest.ini missing"
exit 1
fi

# Test 6: Verify conftest.py exists
echo "Test 6: Verify conftest.py exists..."
if [[ -f "tests/conftest.py" ]]; then
echo "✅ conftest.py exists"
else
echo "❌ conftest.py missing"
exit 1
fi

# Test 7: Run all tests
echo "Test 7: Run full test suite..."
if python -m pytest tests/ -v --tb=short 2>&1; then
echo "✅ All tests passed"
else
echo "❌ Some tests failed"
exit 1
fi

echo ""
echo "=== Pattern 11 (Testing): ALL TESTS PASSED ✅ ==="
Loading