Skip to content

docs: initialize blueprint development structure #376

docs: initialize blueprint development structure

docs: initialize blueprint development structure #376

Workflow file for this run

name: Claude Code
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned, labeled]
pull_request_review:
types: [submitted]
# Prevent duplicate runs - only one Claude run per issue/PR at a time
# Note: cancel-in-progress is disabled to avoid canceling Claude mid-task
concurrency:
group: claude-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }}
cancel-in-progress: false
jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: write # Upgraded from read to allow commits
pull-requests: write # Upgraded to allow PR creation and updates
issues: write # Upgraded to allow issue updates
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better context
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js for MCP servers
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Bun for MCP servers
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Go for GitHub MCP server
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Setup Python/uv for pal-mcp-server
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install pre-commit
run: pip install pre-commit
- name: Install pre-commit dependencies
run: |
brew install chezmoi
- name: Install Claude CLI
run: |
npm install -g @anthropic-ai/claude-code
echo "Claude CLI version: $(claude --version)"
- name: Cache Claude Plugins
uses: actions/cache@v4
with:
path: ~/.claude/plugins
key: claude-plugins-v1-${{ runner.os }}-lgates-claude-plugins
restore-keys: |
claude-plugins-v1-${{ runner.os }}-
- name: Add Claude Plugins Marketplace
run: |
# Add the laurigates/claude-plugins marketplace
claude /plugin marketplace add laurigates/claude-plugins
# Install essential plugins for this repository
claude /plugin install dotfiles-plugin@lgates-claude-plugins
claude /plugin install git-plugin@lgates-claude-plugins
claude /plugin install github-actions-plugin@lgates-claude-plugins
claude /plugin install code-quality-plugin@lgates-claude-plugins
claude /plugin install testing-plugin@lgates-claude-plugins
claude /plugin install tools-plugin@lgates-claude-plugins
# List installed plugins for verification
{
echo "## 🔌 Installed Claude Plugins"
echo ""
echo "Marketplace: \`lgates-claude-plugins\`"
echo ""
echo "Plugins installed:"
echo "- dotfiles-plugin"
echo "- git-plugin"
echo "- github-actions-plugin"
echo "- code-quality-plugin"
echo "- testing-plugin"
echo "- tools-plugin"
} >> "$GITHUB_STEP_SUMMARY"
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Generate allowed tools configuration
id: tools-config
run: |
# Make script executable
chmod +x .github/scripts/generate-allowed-tools.sh
# Generate allowed tools string using full_access preset
ALLOWED_TOOLS=$(.github/scripts/generate-allowed-tools.sh .github/claude-tools-config.json full_access)
# Export to GitHub output
echo "allowed_tools=$ALLOWED_TOOLS" >> "$GITHUB_OUTPUT"
# Show in summary for debugging
{
echo "## 🔧 Allowed Tools Configuration"
echo ""
echo "Preset: \`full_access\`"
echo ""
echo "Tools count: $(echo "$ALLOWED_TOOLS" | tr ',' '\n' | wc -l)"
} >> "$GITHUB_STEP_SUMMARY"
- name: Record start time
id: timing
run: echo "start_time=$(date +%s)" >> "$GITHUB_OUTPUT"
- name: Run Claude Code with MCP Integration
id: claude
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# Enhanced permissions for CI integration
additional_permissions: |
actions: read
# MCP servers configured via .mcp.json in repository root
# Claude Code configuration via CLI arguments
claude_args: |
--model claude-opus-4-5-20251101
--allowedTools ${{ steps.tools-config.outputs.allowed_tools }}
--max-turns 100
- name: Collect workflow metrics
if: always()
run: |
END_TIME=$(date +%s)
START_TIME="${{ steps.timing.outputs.start_time }}"
DURATION=$((END_TIME - START_TIME))
# Create metrics summary
{
echo "## 📊 Workflow Metrics"
echo ""
echo "| Metric | Value |"
echo "|--------|-------|"
echo "| **Duration** | ${DURATION}s |"
echo "| **Trigger** | \`${{ github.event_name }}\` |"
echo "| **Actor** | @${{ github.actor }} |"
echo "| **Run ID** | [\`${{ github.run_id }}\`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |"
echo "| **Status** | ${{ job.status }} |"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
# Save metrics to file
mkdir -p .github/metrics
cat > ".github/metrics/claude-workflow-${{ github.run_id }}.json" <<EOF
{
"run_id": "${{ github.run_id }}",
"run_number": "${{ github.run_number }}",
"event": "${{ github.event_name }}",
"actor": "${{ github.actor }}",
"duration_seconds": ${DURATION},
"status": "${{ job.status }}",
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
- name: Handle workflow failure
if: failure()
run: |
# Create detailed error report
{
echo "## ❌ Workflow Failed"
echo ""
echo "The Claude Code workflow encountered an error."
echo ""
echo "### Error Details"
echo "- **Run ID**: [\`${{ github.run_id }}\`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
echo "- **Triggered by**: \`${{ github.event_name }}\`"
echo "- **Actor**: @${{ github.actor }}"
echo "- **Timestamp**: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo ""
echo "### Troubleshooting Steps"
echo "1. Check the workflow logs for detailed error messages"
echo "2. Verify CLAUDE_CODE_OAUTH_TOKEN secret is configured"
echo "3. Ensure MCP servers in .mcp.json are properly configured"
echo "4. Review recent changes that may have affected the workflow"
} >> "$GITHUB_STEP_SUMMARY"
# Create error notification file
mkdir -p .github/errors
cat > ".github/errors/failure-${{ github.run_id }}.md" <<EOF
# Workflow Failure Report
**Run ID**: ${{ github.run_id }}
**Event**: ${{ github.event_name }}
**Actor**: ${{ github.actor }}
**Timestamp**: $(date -u +%Y-%m-%dT%H:%M:%SZ)
## Context
- Repository: ${{ github.repository }}
- Branch: ${{ github.ref }}
- Commit: ${{ github.sha }}
## Logs
View full logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
- name: Comment on issue/PR with failure details
if: failure() && (github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment')
run: |
COMMENT_BODY="## ❌ Claude Code Workflow Failed
The workflow encountered an error while processing your request.
**Run ID**: [\`${{ github.run_id }}\`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Please check the workflow logs for more details. If this issue persists, please contact the repository maintainers.
<details>
<summary>Technical Details</summary>
- Event: \`${{ github.event_name }}\`
- Actor: @${{ github.actor }}
- Timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)
</details>"
if [ "${{ github.event_name }}" = "issue_comment" ]; then
gh issue comment "${{ github.event.issue.number }}" --body "$COMMENT_BODY"
elif [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
gh pr comment "${{ github.event.pull_request.number }}" --body "$COMMENT_BODY"
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Archive workflow artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: claude-workflow-artifacts
path: |
.claude/tasks/*.md
.claude/tasks/*.json
.claude/docs/*.md
.claude/status/*.md
.github/metrics/*.json
.github/errors/*.md
retention-days: 30