Skip to content
Open
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
152 changes: 152 additions & 0 deletions .claude/commands/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# External DNS Operator - Claude Code Commands

This directory contains custom Claude Code slash commands to help with development and PR review workflows.

## Available Commands

### `/external-dns-operator-helper`

Automated PR review workflow that runs comprehensive quality checks on Pull Requests.

---

## Prerequisites

You need **Claude Code** installed and configured. See [Claude Code Documentation](https://docs.google.com/document/d/1eNARy9CI28o09E7Foq01e5WD5MvEj3LSBnXqFcprxjo/edit?tab=t.0#heading=h.8ldy5by9bpo8) for installation instructions.

---

## How to Use the `/external-dns-operator-helper` Command

### Step 1: Open Claude Code

Launch Claude Code in your terminal or IDE.

### Step 2: Navigate to Repository

Ensure you're in the external-dns-operator repository directory:

```bash
cd /path/to/external-dns-operator
```

### Step 3: Run the Command

In Claude Code, use the slash command with a PR URL:

```
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/123
```

**Replace `123` with the actual PR number you want to review.**

### Step 4: Review the Results

Claude Code will automatically:
1. ✅ Check for uncommitted changes and save your current branch
2. ✅ Checkout the PR
3. ✅ Run `make verify` (lint, format, deps, generated code, OLM)
4. ✅ Run `make test` (unit tests with coverage)
5. ✅ Run `make build` (compilation check)
6. ✅ Perform specialized checks (API changes, tests, docs)
7. ✅ Generate comprehensive report
8. ✅ Return to your original branch

---

## Common Use Cases

### Use Case 1: Pre-Submission PR Check

**Before creating or updating your PR**, validate your changes:

```bash
# 1. Push your changes to your fork
git push origin your-branch-name

# 2. Create the PR (via GitHub UI or gh CLI)
# Get the PR URL, then run:
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/YOUR-PR-NUMBER
```

### Use Case 2: Review Someone Else's PR

**Before manually reviewing**, run automated checks:

```bash
# Someone asks you to review PR #296
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/296
```

If automated checks pass, you can focus on code logic and architecture review.

### Use Case 3: Debugging CI Failures

**When CI fails on your PR**, reproduce locally:

```bash
# Your PR #301 failed CI, check it locally:
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/301
```

The command will show the same errors CI would show, with detailed explanations.

### Use Case 4: Learning Best Practices

**New to the project?** Use it to learn what checks are required:

```bash
# Review a recent merged PR to see what passed:
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/296
```

---

## What the Command Checks

### 1. Linting (`make lint`)
- errcheck, gofmt, goimports, gosimple, govet
- ineffassign, misspell, staticcheck, typecheck, unused
- Configuration: `.golangci.yaml`

### 2. Formatting (`hack/verify-gofmt.sh`)
- All `.go` files must be `gofmt -s` compliant

### 3. Dependencies (`hack/verify-deps.sh`)
- `go.mod` and `go.sum` are in sync
- `vendor/` directory is up-to-date

### 4. Generated Code (`hack/verify-generated.sh`)
- DeepCopy methods are current (`make generate`)
- CRDs, RBAC, webhooks are current (`make manifests`)

### 5. OLM Bundle (`hack/verify-olm.sh`)
- Bundle manifests are up-to-date (`make bundle`)
- Catalog is current (`make catalog`)

### 6. Unit Tests (`make test`)
- All unit tests pass
- No race conditions (runs with `-race`)
- Coverage report generated

### 7. Build Validation (`make build`)
- Operator binary compiles successfully

### 8. Specialized Checks
- API changes → CRD updates
- Controller changes → Test updates
- User-facing changes → Documentation updates
- Kubebuilder markers → Proper documentation

---



## Additional Resources

- **AGENTS.md**: Comprehensive repository development guide
- **CLAUDE.md**: Symlink to AGENTS.md
- **Makefile**: Build targets and CI automation
- **docs/**: External DNS Operator documentation

---
41 changes: 41 additions & 0 deletions .claude/commands/external-dns-operator-helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
```yaml
name: external-dns-operator-helper
description: Run comprehensive PR review workflow for External DNS Operator changes with CI analysis
parameters:
- name: pr_url
description: GitHub PR URL to review (e.g., https://github.com/openshift/external-dns-operator/pull/123)
required: true
```

I'll run a comprehensive automated review of the External DNS Operator PR. This includes checking out the PR, analyzing CI status, validating commits, checking Effective Go style, running local verification, and providing actionable feedback.

```bash
bash .claude/scripts/pr-review.sh "{{pr_url}}"
```

---

## What This Does

**Single command execution** that runs all checks without user interaction:

1. **PR Info** - Shows commits, files changed, PR size
2. **CI Status** - Displays Prow job results with clickable links (no deep log parsing)
3. **Commit Validation** - Checks JIRA-ID format
4. **Effective Go** - Validates receiver names, error strings, exported docs
5. **Make Targets** - Runs verify, test, build
6. **Specialized** - API/CRD sync, controller/test coverage, docs
7. **Summary** - Clear pass/fail report



## Requirements

- Git with `upstream` remote
- `jq` (optional - degrades gracefully without it)

## Usage

```bash
/external-dns-operator-helper https://github.com/openshift/external-dns-operator/pull/294
```
Loading