Skip to content

Commit 289fce3

Browse files
authored
Add files for Claude Code (#252)
1 parent 92695f0 commit 289fce3

6 files changed

Lines changed: 108 additions & 0 deletions

File tree

.claude/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Edit|Write",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "file=$(echo \"$CLAUDE_TOOL_INPUT\" | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('file_path',''))\" 2>/dev/null); if echo \"$file\" | grep -q 'src/.*\\.php$'; then vendor/bin/phpcs src && vendor/bin/phpstan analyse src; fi"
10+
}
11+
]
12+
}
13+
],
14+
"PreToolUse": [
15+
{
16+
"matcher": "Edit|Write",
17+
"hooks": [
18+
{
19+
"type": "command",
20+
"command": "file=$(echo \"$CLAUDE_TOOL_INPUT\" | python3 -c \"import sys,json; d=json.load(sys.stdin); print(d.get('file_path',''))\" 2>/dev/null); if echo \"$file\" | grep -q 'composer\\.lock$'; then echo 'ERROR: composer.lock must only be modified by Composer commands (e.g. composer require, composer update).' >&2; exit 2; fi"
21+
}
22+
]
23+
}
24+
]
25+
}
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: phpstan-fix
3+
description: Run PHPStan and fix all reported errors in src/
4+
---
5+
6+
Run `vendor/bin/phpstan analyse src --error-format=raw`, then fix every reported
7+
error. Prefer adding proper type annotations and null checks over suppressor
8+
comments (`@phpstan-ignore`). Do not change business logic — only satisfy the
9+
type checker. Re-run until the output is clean.

.claude/skills/pr-check/SKILL.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: pr-check
3+
description: Run the full local CI suite before opening a PR
4+
disable-model-invocation: true
5+
---
6+
7+
Run the following checks in order, stopping and reporting on the first failure:
8+
9+
1. `composer validate`
10+
2. `vendor/bin/phpcs src`
11+
3. `vendor/bin/phpstan analyse src`
12+
4. `vendor/bin/phpunit`
13+
14+
Report a summary of all steps (pass/fail). If everything passes, confirm it is
15+
safe to push and open a PR.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
vendor
33
cache
44
.DS_Store
5+
/.claude/settings.local.json
56
/.phpunit.cache
67
/.phpunit.result.cache
78

89
# Binaries
910
/box.phar
1011
/drupalorg.phar
12+

AGENTS.md

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

CLAUDE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# drupalorg-cli
2+
3+
PHP 8.1+ Symfony Console CLI that wraps Drupal.org's REST and JSON:API endpoints. Distributed as a phar.
4+
5+
## Key Commands
6+
7+
| Command | Aliases | Description |
8+
|---|---|---|
9+
| `cache:clear` | `cc` | Clears local API cache |
10+
| `issue:apply` | | Applies latest patch from a Drupal.org issue |
11+
| `issue:branch` | | Creates a local branch for an issue |
12+
| `issue:patch` | | Generates a patch from committed changes |
13+
| `issue:interdiff` | | Generates interdiff between two commits |
14+
| `issue:link` | | Opens issue in browser |
15+
| `issue:show` | | Displays issue details |
16+
| `drupalci:list` | `ci:l` | Lists CI results for an issue |
17+
| `drupalci:watch` | `ci:w` | Polls a CI job until complete |
18+
| `maintainer:issues` | `mi` | Lists issues for a user |
19+
| `maintainer:release-notes` | `rn`, `mrn` | Generates release notes from git log |
20+
| `project:issues` | `pi` | Lists issues for a project |
21+
| `project:releases` | | Lists available releases |
22+
| `project:release-notes` | `prn` | Displays release notes for a release |
23+
| `project:link` | | Opens project page in browser |
24+
| `project:kanban` | | Opens project kanban in browser |
25+
| `travisci:list` | `tci:l` | Lists Travis CI results for an issue |
26+
| `travisci:watch` | `tci:w` | Polls a Travis CI job until complete |
27+
28+
## Architecture
29+
30+
- `src/Api/Client.php` — Guzzle client with cache + retry middleware; `getGuzzleClient()` exposes it for async use
31+
- `src/Api/DrupalOrg.php` — concurrent async requests (JSON:API contributors, issue details, change records) via `GuzzleHttp\Promise\Utils::settle()`
32+
- `src/Api/CommitParser.php` — extracts usernames from classic `by user:` format and Git trailers (`Co-authored-by:` etc.), extracts NIDs from commit titles
33+
- `src/Api/Request.php` / `Response.php` / `RawResponse.php` — request builder and JSON response wrappers
34+
- `src/Cli/Command/Command.php` — base class; provides `$this->client` (Client), `$this->stdOut/stdErr/stdIn`, `runProcess()`
35+
36+
## Development Commands
37+
38+
```bash
39+
vendor/bin/phpcs src # PSR-2 code style (line length excluded)
40+
vendor/bin/phpstan analyse src # Static analysis, level 6
41+
vendor/bin/phpunit # Unit tests (tests/src/)
42+
composer box-install && composer box-build # Build phar
43+
```
44+
45+
## Key Conventions
46+
47+
- PSR-2 code style (line length not enforced)
48+
- PHPStan level 6 with strict + deprecation rules
49+
- Never edit `composer.lock` directly — use `composer require` / `composer update`
50+
- Use concurrent async Guzzle requests (`requestAsync` + `Utils::settle()`) when fetching multiple Drupal.org nodes
51+
52+
## Skills
53+
54+
- `/phpstan-fix` — Run PHPStan and fix all reported errors in `src/`
55+
- `/pr-check` — Run the full local CI suite before opening a PR

0 commit comments

Comments
 (0)