Skip to content

Commit ef015d9

Browse files
docs: expand repository scope to include tools, configs, and best practices (#20)
## Summary This PR expands the repository's scope from a GitHub Actions workflow repository to a **comprehensive Claude AI tooling hub** that includes workflows, custom commands, shared configurations, and development best practices. ## Changes ### CLAUDE.md Updates - ✨ Added Deployment Guard workflow to core workflows overview - 📚 Added "Critical Architectural Insight" explaining the workflow_call event context issue - 🛡️ Added "Development Patterns" section covering ZSH command safety, file management, and version tagging - 📝 Enhanced usage examples with interactive, automatic, and custom trigger patterns - 🔧 Added detailed Deployment Guard documentation including state management and version validation logic - 🗺️ Added "Important Files" section for better repository navigation ### README.md Updates - 🎯 Updated repository tagline and purpose to reflect expanded scope - 📦 Added "What's Inside" section organizing all repository contents - 🛠️ Added "Using Custom Commands" section documenting slash commands and cursor rules - 📂 Added "Repository Structure" visual tree showing complete layout - 🚀 Added "Adopting This Repository's Tooling" section with flexible adoption patterns - 📖 Added "Learn More" and "Contributing" sections - ⚠️ Emphasized version tag best practices throughout ## Why This Matters The repository now serves as a central hub for: - **Reusable GitHub Actions workflows** (orchestrator, executor, deployment guard) - **Custom tools & commands** (like `/weekly-work` for team summaries) - **Shared configurations** (Claude settings, cursor rules) - **Development best practices** (ZSH safety, git workflows, release processes) - **Working examples** (for quick adoption across repositories) This makes it easier for both internal dotCMS teams and external community members to discover, adopt, and contribute to Claude AI tooling. ## Testing - Verified documentation accuracy by reviewing all referenced files and workflows - Confirmed examples use version tags (`@v1.0.0`) instead of `@main` - Validated links to ARCHITECTURE.md, CLAUDE_WORKFLOW_MIGRATION.md, and example files 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 9e1db62 commit ef015d9

2 files changed

Lines changed: 290 additions & 86 deletions

File tree

CLAUDE.md

Lines changed: 113 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,147 +8,184 @@ This repository provides centralized, reusable GitHub Actions workflows for Clau
88

99
## Architecture Overview
1010

11-
The repository implements a simple, reliable architecture:
11+
The repository implements a simple, reliable architecture with three reusable workflows:
1212

1313
### Core Workflows
1414

15-
- **Claude Orchestrator** (`.github/workflows/claude-orchestrator.yml`): A lightweight wrapper that calls the executor with minimal configuration. This is the recommended workflow for consumer repositories (FIXED - no longer has the original architectural issues).
16-
- **Claude Executor** (`.github/workflows/claude-executor.yml`): The execution engine that runs Claude AI actions with configurable tools, timeouts, and runners.
15+
- **Claude Orchestrator** (`.github/workflows/claude-orchestrator.yml`): Lightweight wrapper that handles @claude mention detection and routes to executor. Consumer repositories call this with `trigger_mode: interactive` or `trigger_mode: automatic`.
16+
- **Claude Executor** (`.github/workflows/claude-executor.yml`): Execution engine that runs the `anthropics/claude-code-action@beta` with configured tools, timeouts, and runners.
17+
- **Deployment Guard** (`.github/workflows/deployment-guard.yml`): Reusable workflow for validating deployment changes with configurable rules. Features organization-based bypass for trusted members, file allowlist validation, image-only change detection, and comprehensive image validation (format, repository, version pattern, registry existence, anti-downgrade logic).
1718

18-
### Key Design Patterns
19+
### Critical Architectural Insight
1920

20-
- **Consumer-Handled Triggers**: Consumer repositories handle their own webhook triggers and conditional logic, then call the centralized workflows
21-
- **Simple Reusable Workflows**: The `claude-orchestrator.yml` workflow provides a clean interface to the executor
22-
- **Parameterization**: Workflows accept inputs for customization (prompts, tools, timeouts, runners)
23-
- **Security Isolation**: Each consuming repository must provide its own `ANTHROPIC_API_KEY` for cost tracking and security
21+
The original orchestrator attempted to centralize trigger logic, but GitHub Actions `workflow_call` loses the original webhook event context. When a consumer workflow calls a reusable workflow, `github.event_name` becomes `"workflow_call"` instead of the original event (like `"issue_comment"`), causing all conditional logic to fail.
22+
23+
**Solution**: Consumer repositories handle their own webhook events and conditional logic, then call the centralized workflows only when conditions are met. This prevents double triggering and maintains proper event context.
2424

2525
## Common Commands
2626

2727
### Testing and Validation
2828

2929
```bash
30-
# Lint YAML files
31-
yamllint -c .yamllint.yml **/*.yml **/*.yaml
30+
# Lint all workflows with actionlint (via docker)
31+
docker run --rm -v "${PWD}:/repo" -w /repo rhysd/actionlint:1.7.7
3232

3333
# Validate workflow syntax
3434
python -c "import yaml; yaml.safe_load(open('.github/workflows/claude-orchestrator.yml'))"
3535
python -c "import yaml; yaml.safe_load(open('.github/workflows/claude-executor.yml'))"
36+
python -c "import yaml; yaml.safe_load(open('.github/workflows/deployment-guard.yml'))"
37+
38+
# Run automated tests
39+
# Tests are defined in .github/workflows/tests.yml and run automatically on PR/push to main
3640
```
3741

38-
### Workflow Testing
42+
### Testing Deployment Guard
3943

40-
The repository includes automated tests in `.github/workflows/tests.yml` that:
44+
The deployment-guard workflow includes a `testing_force_non_bypass` parameter for testing validation logic even when you're an organization member. See recent commits `9e1db62` and earlier for refactoring details and state management improvements.
4145

42-
- Lint all YAML files using yamllint configuration
43-
- Validate GitHub Actions workflow syntax
44-
- Check for required workflow elements (name, on, jobs)
45-
- Validate secret requirements in reusable workflows
46+
## Development Patterns
4647

47-
## Configuration Files
48+
### ZSH Command Safety (CRITICAL)
4849

49-
- **`.yamllint.yml`**: YAML linting configuration with 240-character line length limit and 2-space indentation
50-
- **Examples**: `examples/consumer-repo-workflow.yml` shows how consuming repositories should reference these workflows
50+
When using terminal commands, especially git and GitHub CLI operations:
5151

52-
## Usage by Consuming Repositories
52+
- **ALWAYS** use single quotes for simple strings
53+
- **NEVER** use emojis or special characters in inline git/gh commands
54+
- **USE** separate files for complex content (release notes, commit messages) instead of inline strings
55+
- **STOP IMMEDIATELY** (Ctrl+C) if you see `dquote>` or `>` prompts - this means ZSH escaping issues
56+
57+
**Safe patterns:**
58+
```bash
59+
# Good - simple commands with file-based content
60+
git tag v1.0.0
61+
gh release create v1.0.0 --title "Simple Title" --notes-file release-notes.md
62+
63+
# Bad - complex inline content causes ZSH issues
64+
git tag -a v1.0.0 -m "🎉 Release with emojis"
65+
gh release create v1.0.0 --notes "Complex @ content"
66+
```
5367

54-
### Recommended Approach: Consumer-Handled Triggers
68+
### File Management Best Practices
69+
70+
The deployment-guard workflow demonstrates critical state management patterns:
71+
- **NO temporary files** - Use bash arrays and variables instead
72+
- Avoids race conditions and cleanup issues
73+
- See commit `9e1db62` (deployment-guard v2.0.0) for robust state management examples
74+
75+
### Version Tagging
76+
77+
**ALWAYS use version tags** (`@v1.0.0`) instead of `@main` for production workflows:
78+
```yaml
79+
# Production-safe
80+
uses: dotCMS/ai-workflows/.github/workflows/claude-orchestrator.yml@v1.0.0
81+
82+
# Unsafe - can break unexpectedly
83+
uses: dotCMS/ai-workflows/.github/workflows/claude-orchestrator.yml@main
84+
```
5585
56-
The recommended approach is for consumer repositories to handle their own webhook triggers and conditional logic, then call the centralized `claude-orchestrator.yml` workflow. This approach is reliable and avoids the architectural issues with the orchestrator pattern.
86+
## Usage by Consuming Repositories
5787
58-
**Example for interactive @claude mentions:**
88+
Consumer repositories handle their own webhook triggers and conditional logic, then call centralized workflows. This preserves event context and prevents double triggering.
5989
90+
**Interactive mode example (with built-in @claude detection):**
6091
```yaml
6192
jobs:
62-
claude-comment-mention:
63-
if: |
64-
github.event_name == 'issue_comment' && (
65-
contains(github.event.comment.body, '@claude') ||
66-
contains(github.event.comment.body, '@Claude') ||
67-
contains(github.event.comment.body, '@CLAUDE')
68-
)
69-
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
93+
claude-interactive:
94+
uses: dotCMS/ai-workflows/.github/workflows/claude-orchestrator.yml@v1.0.0
7095
with:
7196
trigger_mode: interactive
97+
enable_mention_detection: true # Built-in @claude detection
7298
allowed_tools: |
7399
Bash(terraform plan)
74100
Bash(git status)
75-
timeout_minutes: 15
76101
secrets:
77102
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
78103
```
79104
80-
**Example for automatic PR reviews:**
81-
105+
**Automatic mode example:**
82106
```yaml
83-
claude-automatic-review:
84-
if: |
85-
github.event_name == 'pull_request' &&
86-
!contains(github.event.pull_request.title, '@claude')
87-
uses: dotCMS/claude-workflows/.github/workflows/claude-orchestrator.yml@main
107+
claude-automatic:
108+
if: github.event_name == 'pull_request'
109+
uses: dotCMS/ai-workflows/.github/workflows/claude-orchestrator.yml@v1.0.0
88110
with:
89111
trigger_mode: automatic
112+
enable_mention_detection: false
90113
direct_prompt: |
91-
Please review this pull request and provide feedback...
114+
Please review this pull request for code quality and security.
92115
allowed_tools: |
93116
Bash(terraform plan)
94117
Bash(git status)
95118
secrets:
96119
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
97120
```
98121
99-
### Why This Approach?
122+
**Custom trigger conditions:**
123+
```yaml
124+
claude-security-review:
125+
uses: dotCMS/ai-workflows/.github/workflows/claude-orchestrator.yml@v1.0.0
126+
with:
127+
trigger_mode: automatic
128+
enable_mention_detection: false
129+
custom_trigger_condition: |
130+
github.event_name == 'pull_request' && (
131+
contains(github.event.pull_request.title, 'security') ||
132+
contains(github.event.pull_request.body, 'vulnerability')
133+
)
134+
direct_prompt: Review for security implications.
135+
secrets:
136+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
137+
```
138+
139+
See `examples/` directory for complete working examples.
100140

101-
The original orchestrator design had a fundamental flaw: when called via `workflow_call`, the `github.event_name` becomes `"workflow_call"` instead of the original trigger event (like `"issue_comment"`), causing all conditional logic to fail and resulting in double triggering.
141+
## Deployment Guard Workflow
102142

103-
The consumer-handled approach solves this by:
143+
The deployment-guard workflow provides configurable validation for deployment changes:
104144

105-
1. Consumer workflows handle their own webhook events directly
106-
2. They evaluate trigger conditions using the original event context
107-
3. They call the simple centralized workflow only when conditions are met
108-
4. No double triggering occurs
145+
### Key Features
146+
- **Organization-based bypass**: Public members of a trusted organization bypass all validations
147+
- **File allowlist**: Restrict changes to specific file patterns (glob-based)
148+
- **Image-only validation**: Ensure only container image fields are modified (no resource/env changes)
149+
- **Image validation**: Format, repository, version pattern, registry existence, anti-downgrade checking
150+
- **Testing mode**: `testing_force_non_bypass: true` to test validation logic even as org member
109151

110-
See the complete examples in the `examples/` directory:
152+
### State Management Pattern
153+
The deployment-guard demonstrates robust bash state management without temporary files (see `deployment-guard.yml:227-252` and `297-382`):
154+
- Uses bash arrays instead of temp files to avoid race conditions
155+
- Proper error handling with `set -euo pipefail`
156+
- Clear state tracking with boolean flags
111157

112-
- `examples/consumer-repo-workflow.yml` - General purpose example
113-
- `examples/infrastructure-consumer-workflow.yml` - Infrastructure-specific example
158+
### Version Validation Logic
159+
Sophisticated version comparison supporting dotCMS format: `YY.MM.DD[-REBUILD][_HASH]`
160+
- Prevents downgrades at base version level (25.12.08 → 25.12.07)
161+
- Prevents rebuild downgrades (25.12.08-2 → 25.12.08-1)
162+
- Allows hash changes for same version (25.12.08_abc → 25.12.08_def)
114163

115164
## Security Requirements
116165

117166
- Each consuming repository MUST provide its own `ANTHROPIC_API_KEY` secret
118167
- API keys are required for cost tracking, security isolation, and usage control
119168
- Workflows will fail if the API key is not provided
120-
121-
## Workflow Triggers Supported
122-
123-
- Interactive @claude mentions (case-insensitive) in:
124-
- Issue comments
125-
- Pull request review comments
126-
- Pull request reviews
127-
- Issue titles/bodies
128-
- Pull request titles/bodies
129-
- Automatic pull request reviews (when no @claude mention is present)
169+
- Never commit secrets to version control
130170

131171
## Default Configuration
132172

173+
### Claude Workflows
133174
- **Timeout**: 15 minutes
134-
- **Runner**: ubuntu-latest
175+
- **Runner**: ubuntu-latest
135176
- **Default Tools**: `git status` and `git diff`
136-
- **Concurrency**: Consumer repositories should implement concurrency control:
137-
138-
```yaml
139-
concurrency:
140-
group: claude-${{ github.event.pull_request.number || github.event.issue.number || 'manual' }}
141-
cancel-in-progress: false
142-
```
143-
144-
## Migration from Old Orchestrator
177+
- **Mention Detection**: Case-insensitive @claude in comments, reviews, issues, and PRs
178+
- **Concurrency**: Consumer repositories should implement concurrency control to prevent duplicate runs
145179

146-
If you're currently using the old version of `claude-orchestrator.yml` workflow that had double triggering issues, migrate to the new pattern:
180+
### Deployment Guard
181+
- **Organization bypass**: Disabled by default (must configure `trusted_organization`)
182+
- **All validations**: Enabled by default
183+
- **Image verification**: Checks Docker Hub by default
147184

148-
1. Replace the single orchestrator call with multiple jobs that handle different trigger conditions
149-
2. Each job should call the fixed `claude-orchestrator.yml` with appropriate `trigger_mode`
150-
3. Add proper concurrency control to your consumer workflow
151-
4. Test that @claude mentions and automatic reviews work without double triggering
185+
## Important Files
152186

153-
See the example files for complete migration templates.
187+
- **ARCHITECTURE.md**: Deep dive into workflow architecture and why consumer-handled triggers are necessary
188+
- **CLAUDE_WORKFLOW_MIGRATION.md**: Step-by-step migration guide from pilot workflows
189+
- **.cursor/rules/**: Modular development rules covering terminal commands, git workflow, release process, error prevention, and collaboration patterns
190+
- **examples/**: Working examples for general-purpose, infrastructure, and advanced custom triggers
154191

0 commit comments

Comments
 (0)