Skip to content

Commit 8e2726c

Browse files
doc updates
1 parent 3684c31 commit 8e2726c

3 files changed

Lines changed: 258 additions & 45 deletions

File tree

CLAUDE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Repository Purpose
6+
7+
This repository provides centralized, reusable GitHub Actions workflows for Claude AI integration across dotCMS and related projects. It implements a DRY approach by consolidating Claude workflow logic into orchestrator and executor patterns that can be consumed by other repositories.
8+
9+
## Architecture Overview
10+
11+
The repository implements a two-workflow architecture:
12+
13+
### Core Workflows
14+
- **Claude Orchestrator** (`.github/workflows/claude-orchestrator.yml`): Routes different trigger types (PR events, comments, issues) to appropriate execution modes. Handles both interactive (@claude mentions) and automatic review modes.
15+
- **Claude Executor** (`.github/workflows/claude-executor.yml`): The execution engine that runs Claude AI actions with configurable tools, timeouts, and runners.
16+
17+
### Key Design Patterns
18+
- **Reusable Workflows**: Both workflows use `workflow_call` to be consumed by other repositories
19+
- **Conditional Execution**: Orchestrator prevents duplicate runs by routing triggers to specific jobs
20+
- **Parameterization**: Workflows accept inputs for customization (prompts, tools, timeouts, runners)
21+
- **Security Isolation**: Each consuming repository must provide its own `ANTHROPIC_API_KEY` for cost tracking and security
22+
23+
## Common Commands
24+
25+
### Testing and Validation
26+
```bash
27+
# Lint YAML files
28+
yamllint -c .yamllint.yml **/*.yml **/*.yaml
29+
30+
# Validate workflow syntax
31+
python -c "import yaml; yaml.safe_load(open('.github/workflows/claude-orchestrator.yml'))"
32+
python -c "import yaml; yaml.safe_load(open('.github/workflows/claude-executor.yml'))"
33+
```
34+
35+
### Workflow Testing
36+
The repository includes automated tests in `.github/workflows/tests.yml` that:
37+
- Lint all YAML files using yamllint configuration
38+
- Validate GitHub Actions workflow syntax
39+
- Check for required workflow elements (name, on, jobs)
40+
- Validate secret requirements in reusable workflows
41+
42+
## Configuration Files
43+
44+
- **`.yamllint.yml`**: YAML linting configuration with 240-character line length limit and 2-space indentation
45+
- **Examples**: `examples/consumer-repo-workflow.yml` shows how consuming repositories should reference these workflows
46+
47+
## Usage by Consuming Repositories
48+
49+
Repositories use this workflow by creating a workflow file that calls the orchestrator:
50+
51+
```yaml
52+
jobs:
53+
claude:
54+
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
55+
with:
56+
# Repository-specific configurations
57+
allowed_tools: |
58+
Bash(terraform plan)
59+
Bash(git status)
60+
automatic_review_prompt: |
61+
Custom review prompt for this repository
62+
secrets:
63+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
64+
```
65+
66+
## Security Requirements
67+
68+
- Each consuming repository MUST provide its own `ANTHROPIC_API_KEY` secret
69+
- API keys are required for cost tracking, security isolation, and usage control
70+
- Workflows will fail if the API key is not provided
71+
72+
## Workflow Triggers Supported
73+
74+
- Interactive @claude mentions (case-insensitive) in:
75+
- Issue comments
76+
- Pull request review comments
77+
- Pull request reviews
78+
- Issue titles/bodies
79+
- Pull request titles/bodies
80+
- Automatic pull request reviews (when no @claude mention is present)
81+
82+
## Default Configuration
83+
84+
- **Timeout**: 15 minutes
85+
- **Runner**: ubuntu-latest
86+
- **Default Tools**: `git status` and `git diff`
87+
- **Concurrency**: Prevents multiple Claude jobs per PR/issue

CLAUDE_WORKFLOW_MIGRATION.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Claude Workflow Migration Guide
2+
3+
> **Note:** For main usage instructions and up-to-date examples, see [README.md](./README.md).
4+
5+
## Overview
6+
This document outlines the migration of Claude AI workflows to the centralized `dotCMS/claude-workflows` repository to implement DRY principles and enable reuse across multiple repositories.
7+
8+
## Files Created for claude-workflows Repository
9+
10+
The following files should exist in the `dotCMS/claude-workflows` repository:
11+
12+
### 1. `.github/workflows/claude-executor.yml`
13+
Location: `claude-executor-reusable.yml` (rename to `claude-executor.yml`)
14+
- Reusable workflow that handles Claude AI execution
15+
- Configurable allowed tools, timeout, and runner
16+
- Accepts trigger mode and direct prompt inputs
17+
18+
### 2. `.github/workflows/claude-orchestrator.yml`
19+
Location: `claude-orchestrator-reusable.yml` (rename to `claude-orchestrator.yml`)
20+
- Reusable workflow that orchestrates Claude interactions
21+
- Handles all trigger events (comments, PRs, issues)
22+
- Configurable prompts, tools, and executor workflow reference
23+
24+
## Migration Benefits
25+
26+
### Before (Current State)
27+
- Each repository maintains its own Claude workflow files
28+
- Duplication of logic across repositories
29+
- Updates require changes in multiple places
30+
- Inconsistent configurations between repositories
31+
32+
### After (Centralized State)
33+
- Single source of truth for Claude workflows
34+
- Repository-specific configurations via parameters
35+
- Easier maintenance and updates
36+
- Consistent behavior across all repositories
37+
- DRY principle implementation
38+
39+
## Implementation Steps
40+
41+
### Step 1: Ensure Files Exist in claude-workflows Repository
42+
43+
> **Historical Note:** This step is already completed in this repository. The required workflows are present and correctly named. For forks or future migrations, ensure the following files exist in the correct locations:
44+
> - `.github/workflows/claude-executor.yml`
45+
> - `.github/workflows/claude-orchestrator.yml`
46+
47+
### Step 2: Repository Configuration
48+
The infrastructure-as-code repository has been updated to:
49+
- Reference centralized workflows from `dotCMS/claude-workflows`
50+
- Maintain infrastructure-specific configurations:
51+
- Terraform/Terragrunt allowed tools
52+
- Cost-aware automatic review prompts
53+
- Customer path exclusions
54+
55+
### Step 3: Validation
56+
After setup, test the workflows by:
57+
1. Creating a test PR
58+
2. Verifying automatic reviews work
59+
3. Testing @claude mentions in comments
60+
4. Confirming path exclusions still apply
61+
62+
## Key Features Preserved
63+
64+
### Infrastructure-Specific Configurations
65+
- **Allowed Tools**: Terraform, Terragrunt, and Git commands
66+
- **Automatic Review Prompt**: Includes cost impact analysis
67+
- **Path Exclusions**: Customer-specific Kubernetes files ignored
68+
- **Timeout**: 15-minute execution limit
69+
- **Runner**: Ubuntu-latest
70+
71+
### Workflow Triggers
72+
- Interactive @claude mentions (case-insensitive)
73+
- Automatic PR reviews (when no @claude mention)
74+
- Issue comments and reviews
75+
- Pull request events
76+
77+
### Concurrency Control
78+
- Prevents multiple Claude jobs per PR/issue
79+
- Maintains existing behavior
80+
81+
## Next Steps
82+
83+
1. **Ensure reusable workflows exist** in claude-workflows repository (already done here)
84+
2. **Test the migration** with a sample PR
85+
3. **Apply to other repositories** using the same pattern
86+
4. **Document usage** for other teams
87+
88+
## Benefits for Other Repositories
89+
90+
Other dotCMS repositories can now easily add Claude support by:
91+
1. Creating a simple orchestrator workflow that calls the centralized version
92+
2. Customizing allowed tools for their specific needs
93+
3. Setting repository-specific prompts and configurations
94+
4. Maintaining consistent Claude behavior across the organization
95+
96+
This migration addresses issue [dotCMS/dotcat#213](https://github.com/dotCMS/dotcat/issues/213) and establishes the foundation for organization-wide Claude workflow standardization.

README.md

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,66 @@
11
# claude-workflows
22
Reusable Claude AI GitHub Actions workflows and config for dotCMS and related projects
33

4+
## 🚀 Centralized Claude Workflows: Migration & Overview
5+
6+
**This repository now provides a centralized, reusable system for all Claude AI GitHub Actions workflows.**
7+
8+
- **Replaces the pilot workflow previously used in `dotcms/infrastructure-as-code`.**
9+
- **Keeps things DRY and maintainable** by consolidating logic into orchestrator and executor workflows.
10+
- **Still allows full repo-level customization** via workflow inputs (prompts, allowed tools, runners, etc.).
11+
12+
---
13+
14+
## Migration Guide: From Pilot to Centralized Workflows
15+
16+
If you previously used the pilot Claude workflow in `dotcms/infrastructure-as-code`, follow these steps:
17+
18+
1. **Remove references to the old pilot workflow** in your repository's workflow files.
19+
2. **Update your workflow to use the new orchestrator:**
20+
21+
```yaml
22+
jobs:
23+
claude:
24+
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
25+
with:
26+
# Customize as needed for your repo
27+
allowed_tools: |
28+
Bash(terraform plan)
29+
Bash(git status)
30+
automatic_review_prompt: |
31+
Please review this pull request for code quality, security, and best practices.
32+
secrets:
33+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
34+
```
35+
3. **Configure your `ANTHROPIC_API_KEY` secret** as described below.
36+
4. **(Optional) Customize prompts, allowed tools, and runner as needed.**
37+
38+
---
39+
40+
## 📚 Migration Details
41+
42+
For a comprehensive migration guide—including step-by-step instructions, validation tips, and infrastructure-specific configuration examples—see [CLAUDE_WORKFLOW_MIGRATION.md](./CLAUDE_WORKFLOW_MIGRATION.md).
43+
44+
---
45+
46+
## Top-Level Points
47+
48+
- **Centralized, DRY, and maintainable:** All Claude logic is now in one place, making updates and improvements easy.
49+
- **Repo-level flexibility:** Each repository can override prompts, tools, and other settings via workflow inputs.
50+
- **Security & cost management:** Each repo must provide its own Anthropic API key for isolation and accountability.
51+
- **No more standalone code review workflow:** All code review and other Claude actions are routed through the orchestrator/executor pattern.
52+
53+
---
54+
455
## Important: Security and Cost Management
556

657
**⚠️ API Key Requirement**: All workflows in this repository require each consuming repository to provide its own Anthropic API key. This is a mandatory security and cost management requirement.
758

859
**Why we require per-repository API keys:**
960

1061
1. **Cost Tracking & Accountability**: Each repository's Claude AI usage is tracked separately in the Anthropic console, allowing for detailed cost attribution and budget management per project.
11-
1262
2. **Security Isolation**: If a repository experiences unauthorized or excessive usage, it only affects that repository's API key and budget, not a shared organizational key.
13-
1463
3. **Usage Control**: Individual repositories can set their own API limits and monitoring, preventing runaway costs from affecting other projects.
15-
1664
4. **Compliance**: Many organizations require API key isolation for audit trails and security compliance.
1765

1866
**What this means for you:**
@@ -21,17 +69,17 @@ Reusable Claude AI GitHub Actions workflows and config for dotCMS and related pr
2169
- The workflow will **fail** if the API key is not provided
2270
- Each repository is responsible for its own API costs and usage
2371

72+
---
73+
2474
## Available Workflows
2575

26-
### Claude Code Review (`claude-code-review.yml`)
27-
Provides AI-powered code review using Claude AI for pull requests and commits.
76+
### Claude Orchestrator (`claude-orchestrator.yml`)
77+
Routes all Claude triggers (PRs, issues, comments, reviews) to the correct execution mode and calls the executor workflow.
78+
79+
### Claude Executor (`claude-executor.yml`)
80+
Handles the actual execution of Claude actions, with configurable parameters (prompts, allowed tools, runner, etc.).
2881

29-
**Features:**
30-
- Reviews changed files in PRs automatically
31-
- Configurable review focus (general, security, performance, best-practices)
32-
- Posts review comments directly on PRs
33-
- Supports custom file selection
34-
- Uploads review artifacts
82+
---
3583

3684
## Setup Instructions
3785

@@ -42,14 +90,9 @@ Each consuming repository must configure its own Anthropic API key:
4290
2. Create a new repository secret named `ANTHROPIC_API_KEY`
4391
3. Set the value to your Anthropic API key
4492

45-
**Benefits of per-repository API keys:**
46-
- **Cost Tracking**: Each repository's usage is tracked separately in the Anthropic console
47-
- **Security Isolation**: Unauthorized usage in one repo won't affect others
48-
- **Usage Control**: Individual repos can manage their own API limits
49-
50-
### 2. Using the Claude Code Review Workflow
93+
### 2. Using the Centralized Claude Workflow
5194

52-
Create a workflow file in your repository at `.github/workflows/claude-review.yml`:
95+
Create a workflow file in your repository at `.github/workflows/claude-review.yml` (or similar):
5396

5497
```yaml
5598
name: PR Code Review with Claude
@@ -60,18 +103,16 @@ on:
60103
branches: [ main, develop ]
61104
62105
jobs:
63-
claude-review:
64-
name: Claude AI Code Review
65-
uses: dotCMS/claude-workflows/.github/workflows/claude-code-review.yml@main
106+
claude:
107+
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
66108
with:
67-
# Optional: Set review focus
68-
review_focus: 'security' # Options: general, security, performance, best-practices
69-
70-
# Optional: Maximum number of files to review
71-
max_files: 15
72-
73-
# Optional: Specify specific files (defaults to all changed files)
74-
# files_to_review: 'src/main.js,src/utils.js'
109+
# Optional: Customize allowed tools
110+
allowed_tools: |
111+
Bash(terraform plan)
112+
Bash(git status)
113+
# Optional: Customize review prompt
114+
automatic_review_prompt: |
115+
Please review this pull request for code quality, security, and best practices.
75116
secrets:
76117
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
77118
```
@@ -80,23 +121,12 @@ jobs:
80121

81122
| Input | Description | Required | Default |
82123
|-------|-------------|----------|---------|
83-
| `files_to_review` | Comma-separated list of specific files to review | No | All changed files |
84-
| `review_focus` | Review focus area | No | `general` |
85-
| `max_files` | Maximum number of files to review | No | `10` |
86-
87-
**Review Focus Options:**
88-
- `general`: Overall code quality, bugs, and improvements
89-
- `security`: Security vulnerabilities and best practices
90-
- `performance`: Performance issues and optimizations
91-
- `best-practices`: Code quality and maintainability
92-
93-
### 4. Required Secrets
94-
95-
| Secret | Description | Required | Notes |
96-
|--------|-------------|----------|-------|
97-
| `ANTHROPIC_API_KEY` | Your repository's Anthropic API key | **Yes** | Must be configured in each consuming repository. The workflow will fail without this secret. |
124+
| `automatic_review_prompt` | Custom prompt for automatic PR reviews | No | See orchestrator default |
125+
| `allowed_tools` | Custom allowed tools configuration | No | See orchestrator default |
126+
| `timeout_minutes` | Timeout for Claude execution | No | 15 |
127+
| `runner` | GitHub runner to use | No | ubuntu-latest |
98128

99-
**⚠️ Critical**: The `ANTHROPIC_API_KEY` secret is mandatory and must be passed to the reusable workflow. This is not optional - it's a security and cost management requirement. See the "Security and Cost Management" section above for details.
129+
---
100130

101131
## Examples
102132

0 commit comments

Comments
 (0)