Skip to content

Commit 1720668

Browse files
ci: add claude code github workflow (#1487)
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * docs: create CLAUDE.md and update AGENTS.md * chore(cspell): add missing words * chore: nits
1 parent 9891639 commit 1720668

5 files changed

Lines changed: 153 additions & 5 deletions

File tree

.github/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"gradlew",
3232
"fluttium",
3333
"clsx",
34+
"Dartdoc",
3435
"mockingjay"
3536
]
3637
}

.github/workflows/claude.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: claude_code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
issues: read
23+
actions: read # Required for Claude to read CI results on PRs
24+
contents: read
25+
id-token: write
26+
pull-requests: read
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@v1
36+
with:
37+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38+
claude_args: |
39+
--max-turns 5
40+
--model claude-opus-4-6
41+
# This is an optional setting that allows Claude to read CI results on PRs
42+
additional_permissions: |
43+
actions: read
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: claude_code_review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
7+
jobs:
8+
claude-review:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: read
12+
contents: read
13+
id-token: write
14+
pull-requests: read
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Run Claude Code Review
23+
id: claude-review
24+
uses: anthropics/claude-code-action@v1
25+
with:
26+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
27+
plugin_marketplaces: "https://github.com/anthropics/claude-code.git"
28+
plugins: "code-review@claude-code-plugins"
29+
prompt: "/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
30+
claude_args: |
31+
--max-turns 5
32+
--model claude-opus-4-6

AGENTS.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,82 @@ Our criteria for good code also enables us to achieve 100% test coverage.
1111

1212
Good code has...
1313

14-
- as few branches as possible
15-
- injectable dependencies
16-
- well-named identifiers
17-
- no sibling dependencies in the same architectural layer
14+
- As few branches as possible
15+
- Injectable dependencies
16+
- Well-named identifiers
17+
- No sibling dependencies in the same architectural layer
1818

1919
To avoid sibling dependencies, state must either be lifted up to a common ancestor and passed down, or pushed down and subscribed to.
2020

21-
See CONTRIBUTING.md for development details.
21+
See @CONTRIBUTING.md for development details.
22+
23+
## Project Overview
24+
25+
Very Good CLI is a Dart command-line tool by Very Good Ventures for generating scalable project templates and running developer commands. It is published on pub.dev as `very_good_cli`.
26+
27+
## Common Commands
28+
29+
```bash
30+
# Install dependencies
31+
dart pub get && cd bricks/test_optimizer && dart pub get && cd ../../
32+
33+
# Run unit tests (excludes expensive pull-request-only and e2e tests)
34+
flutter test -x pull-request-only -x e2e
35+
36+
# Run a single test file
37+
flutter test test/src/commands/create/create_test.dart
38+
39+
# Format code
40+
dart format lib test
41+
42+
# Analyze code (strict: warnings and infos are fatal)
43+
dart analyze --fatal-infos --fatal-warnings .
44+
45+
# Auto-fix lint issues
46+
dart fix --apply
47+
48+
# Activate local dev version
49+
dart pub global activate --source path .
50+
```
51+
52+
## Architecture
53+
54+
### Command Runner Pattern
55+
56+
Entry point: `bin/very_good.dart``VeryGoodCommandRunner` (extends `CompletionCommandRunner<int>`).
57+
58+
All commands return `Future<int>` (exit codes from `universal_io`'s `ExitCode`). Top-level commands: `create`, `test`, `packages`, `dart`, `update`, `mcp`.
59+
60+
### Create Command System
61+
62+
`CreateCommand` has subcommands for each template type (flutter_app, dart_package, dart_cli, docs_site, flame_game, flutter_package, flutter_plugin).
63+
64+
All subcommands extend `CreateSubCommand` and use mixins for optional features:
65+
- `OrgName` — adds `--org-name` flag
66+
- `MultiTemplates` — supports `--template` flag with multiple template choices
67+
- `Publishable` — adds `--publishable` flag
68+
69+
Templates use Mason for code generation. Each template has a bundle, a `Template` class, and an `onGenerateComplete` hook. Template source code lives in separate repos under `VeryGoodOpenSource/very_good_templates`.
70+
71+
### CLI Abstraction Layer (`lib/src/cli/`)
72+
73+
- `DartCli`, `FlutterCli`, `GitCli` — wrappers around shell commands
74+
- `ProcessOverrides` — zone-based dependency injection for mocking `Process.run` in tests
75+
- `TestCliRunner` — test execution logic with coverage collection
76+
77+
### Testing Patterns
78+
79+
- **100% test coverage required** for all PRs
80+
- Mocking with `mocktail`
81+
- Constructor injection for dependencies (`Logger`, `PubUpdater`, generators)
82+
- `@visibleForTesting` used for test-only overrides (e.g., `argResultOverrides`)
83+
- Test tags in `dart_test.yaml`: `pull-request-only` for expensive CI-only tests
84+
- E2E tests in `e2e/` create real projects and run full workflows
85+
- Test optimizer brick in `bricks/test_optimizer/` generates optimized test entry points
86+
87+
## Code Conventions
88+
89+
- Linting: `very_good_analysis` (strict Dart analysis rules)
90+
- Dartdoc templates: `/// {@template name}...{@endtemplate}` / `/// {@macro name}`
91+
- Commits follow [Conventional Commits](https://www.conventionalcommits.org/) (used by release-please for automated versioning)
92+
- `lib/src/version.dart` is auto-generated — do not edit manually

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

0 commit comments

Comments
 (0)