Skip to content

Commit e41c3af

Browse files
committed
Merge branch 'agents'
2 parents 5f6ccfb + 99604cf commit e41c3af

File tree

10 files changed

+335
-56
lines changed

10 files changed

+335
-56
lines changed

.claude/commands/code-review.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
allowed-tools: Bash(gh issue view:*), Bash(gh search:*), Bash(gh issue list:*), Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*), Bash(gh pr list:*), mcp__github_inline_comment__create_inline_comment
3+
description: Code review a pull request
4+
---
5+
6+
Provide a code review for the given pull request.
7+
8+
**Agent assumptions (applies to all agents and subagents):**
9+
- All tools are functional and will work without error. Do not test tools or make exploratory calls. Make sure this is clear to every subagent that is launched.
10+
- Only call a tool if it is required to complete the task. Every tool call should have a clear purpose.
11+
12+
To do this, follow these steps precisely:
13+
14+
1. Launch a haiku agent to check if any of the following are true:
15+
- The pull request is closed
16+
- The pull request is a draft
17+
- The pull request does not need code review (e.g. automated PR, trivial change that is obviously correct)
18+
- Claude has already commented on this PR (check `gh pr view <PR> --comments` for comments left by claude)
19+
20+
If any condition is true, stop and do not proceed.
21+
22+
Note: Still review Claude generated PR's.
23+
24+
2. Launch a haiku agent to return a list of file paths (not their contents) for all relevant CLAUDE.md files including:
25+
- The root CLAUDE.md file, if it exists
26+
- Any CLAUDE.md files in directories containing files modified by the pull request
27+
28+
3. Launch a sonnet agent to view the pull request and return a summary of the changes
29+
30+
4. Launch 4 agents in parallel to independently review the changes. Each agent should return the list of issues, where each issue includes a description and the reason it was flagged (e.g. "CLAUDE.md adherence", "bug"). The agents should do the following:
31+
32+
Agents 1 + 2: CLAUDE.md compliance sonnet agents
33+
Audit changes for CLAUDE.md compliance in parallel. Note: When evaluating CLAUDE.md compliance for a file, you should only consider CLAUDE.md files that share a file path with the file or parents.
34+
35+
Agent 3: Opus bug agent (parallel subagent with agent 4)
36+
Scan for obvious bugs. Focus only on the diff itself without reading extra context. Flag only significant bugs; ignore nitpicks and likely false positives. Do not flag issues that you cannot validate without looking at context outside of the git diff.
37+
38+
Agent 4: Opus bug agent (parallel subagent with agent 3)
39+
Look for problems that exist in the introduced code. This could be security issues, incorrect logic, etc. Only look for issues that fall within the changed code.
40+
41+
**CRITICAL: We only want HIGH SIGNAL issues.** Flag issues where:
42+
- The code will fail to compile or parse (syntax errors, type errors, missing imports, unresolved references)
43+
- The code will definitely produce wrong results regardless of inputs (clear logic errors)
44+
- Clear, unambiguous CLAUDE.md violations where you can quote the exact rule being broken
45+
46+
Do NOT flag:
47+
- Code style or quality concerns
48+
- Potential issues that depend on specific inputs or state
49+
- Subjective suggestions or improvements
50+
51+
If you are not certain an issue is real, do not flag it. False positives erode trust and waste reviewer time.
52+
53+
In addition to the above, each subagent should be told the PR title and description. This will help provide context regarding the author's intent.
54+
55+
5. For each issue found in the previous step by agents 3 and 4, launch parallel subagents to validate the issue. These subagents should get the PR title and description along with a description of the issue. The agent's job is to review the issue to validate that the stated issue is truly an issue with high confidence. For example, if an issue such as "variable is not defined" was flagged, the subagent's job would be to validate that is actually true in the code. Another example would be CLAUDE.md issues. The agent should validate that the CLAUDE.md rule that was violated is scoped for this file and is actually violated. Use Opus subagents for bugs and logic issues, and sonnet agents for CLAUDE.md violations.
56+
57+
6. Filter out any issues that were not validated in step 5. This step will give us our list of high signal issues for our review.
58+
59+
7. Output a summary of the review findings to the terminal:
60+
- If issues were found, list each issue with a brief description.
61+
- If no issues were found, state: "No issues found. Checked for bugs and CLAUDE.md compliance."
62+
63+
If `--comment` argument was NOT provided, stop here. Do not post any GitHub comments.
64+
65+
If `--comment` argument IS provided and NO issues were found, post a summary comment using `gh pr comment` and stop.
66+
67+
If `--comment` argument IS provided and issues were found, continue to step 8.
68+
69+
8. Create a list of all comments that you plan on leaving. This is only for you to make sure you are comfortable with the comments. Do not post this list anywhere.
70+
71+
9. Post inline comments for each issue using `mcp__github_inline_comment__create_inline_comment` with `confirmed: true`. For each comment:
72+
- Provide a brief description of the issue
73+
- For small, self-contained fixes, include a committable suggestion block
74+
- For larger fixes (6+ lines, structural changes, or changes spanning multiple locations), describe the issue and suggested fix without a suggestion block
75+
- Never post a committable suggestion UNLESS committing the suggestion fixes the issue entirely. If follow up steps are required, do not leave a committable suggestion.
76+
77+
**IMPORTANT: Only post ONE comment per unique issue. Do not post duplicate comments.**
78+
79+
Use this list when evaluating issues in Steps 4 and 5 (these are false positives, do NOT flag):
80+
81+
- Pre-existing issues
82+
- Something that appears to be a bug but is actually correct
83+
- Pedantic nitpicks that a senior engineer would not flag
84+
- Issues that a linter will catch (do not run the linter to verify)
85+
- General code quality concerns (e.g., lack of test coverage, general security issues) unless explicitly required in CLAUDE.md
86+
- Issues mentioned in CLAUDE.md but explicitly silenced in the code (e.g., via a lint ignore comment)
87+
88+
Notes:
89+
90+
- Use gh CLI to interact with GitHub (e.g., fetch pull requests, create comments). Do not use web fetch.
91+
- Create a todo list before starting.
92+
- You must cite and link each issue in inline comments (e.g., if referring to a CLAUDE.md, include a link to it).
93+
- If no issues are found and `--comment` argument is provided, post a comment with the following format:
94+
95+
---
96+
97+
## Code review
98+
99+
No issues found. Checked for bugs and CLAUDE.md compliance.
100+
101+
---
102+
103+
- When linking to code in inline comments, follow the following format precisely, otherwise the Markdown preview won't render correctly: https://github.com/anthropics/claude-code/blob/c21d3c10bc8e898b7ac1a2d745bdc9bc4e423afe/package.json#L10-L15
104+
- Requires full git sha
105+
- You must provide the full sha. Commands like `https://github.com/owner/repo/blob/$(git rev-parse HEAD)/foo/bar` will not work, since your comment will be directly rendered in Markdown.
106+
- Repo name must match the repo you're code reviewing
107+
- # sign after the file name
108+
- Line range format is L[start]-L[end]
109+
- Provide at least 1 line of context before and after, centered on the line you are commenting about (eg. if you are commenting about lines 5-6, you should link to `L4-7`)

AGENTS.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Agent guidelines for Dirigent development
2+
3+
Dirigent is a free and open package registry for Composer, the PHP package manager. It allows users to publish private packages and mirror packages from external registries like Packagist.
4+
5+
### Project structure
6+
7+
```
8+
assets/ # Frontend assets
9+
config/ # Symfony configuration
10+
migrations/ # Doctrine migrations (PostgreSQL)
11+
src/
12+
├── Attribute/ # PHP attributes
13+
├── Command/ # Symfony console commands
14+
├── Composer/ # Composer integration logic
15+
├── Controller/ # HTTP controllers
16+
│ └── Dashboard/ # EasyAdmin dashboard controllers
17+
├── Doctrine/
18+
│ ├── Entity/ # Doctrine ORM entities
19+
│ ├── Repository/ # Doctrine repositories
20+
│ ├── Type/ # Custom Doctrine types
21+
│ └── DataFixtures/ # Database fixtures
22+
├── Encryption/ # Encryption utilities
23+
├── Entity/ # Enums (UserRole, PackageUpdateSource)
24+
├── EventListener/ # Symfony event listeners
25+
├── Form/ # Symfony form types
26+
├── Message/ # Symfony messenger messages and handlers (async jobs)
27+
├── Package/ # Package management services
28+
├── Routing/ # Symfony routing logic
29+
├── Twig/ # Twig extensions
30+
└── Validator/ # Symfony validators
31+
templates/ # Twig templates
32+
tests/
33+
├── UnitTests/ # Unit tests
34+
├── FunctionalTests/ # Functional/Integration tests
35+
└── Docker/ # Docker image tests
36+
```
37+
38+
## Coding style
39+
40+
### Project
41+
42+
- Environment variables are stored in `.env.dirigent` and `.env.dirigent.*` (not `.env`).
43+
44+
### PHP
45+
46+
- Follow the PER coding style and the Symfony coding standards.
47+
- Organize services into domain-specific namespaces.
48+
- Always use strict comparisons (`===`, `!==`).
49+
- Enforce the use of DateTimeImmutable over DateTime.
50+
- Always use spaces in concatenation (`$a . $b`).
51+
- Always use imports. Use aliases when collisions occur or the imported name is unclear.
52+
- Don't use blank lines between import groups.
53+
54+
## Commands
55+
56+
### Linting & code quality
57+
58+
```shell
59+
# Run all linting jobs
60+
symfony composer lint
61+
62+
# Individual linters
63+
symfony composer lint:refactor # Rector (automatically applies changes)
64+
symfony composer lint:coding-style # PHP-CS-Fixer (automatically applies changes)
65+
symfony composer lint:static-analysis # PHPStan level 5
66+
symfony composer lint:container # Symfony container validation
67+
symfony composer lint:templates # Twig template validation
68+
```
69+
70+
### Testing
71+
72+
```shell
73+
# Prepare the Symfony test environment for tests (if the database schema changed)
74+
symfony composer tests:setup
75+
76+
# Run all tests
77+
symfony composer tests
78+
79+
# Run only PHP tests
80+
symfony composer tests:php
81+
symfony composer tests:php:unit
82+
symfony composer tests:php:functional
83+
84+
# Run tests for Docker images
85+
symfony composer tests:docker
86+
```

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Agent guidelines for Dirigent development in Claude Code
2+
3+
@AGENTS.md

CONTRIBUTING.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Contributing to Dirigent
2+
3+
Dirigent is an open-source project, contributions of all kind are welcome, including
4+
[financial contributions][codedmonkey-sponsor].
5+
6+
This guide contains technical information and instructions about the development process of the project that you should
7+
follow when contributing code.
8+
9+
## Project information
10+
11+
### Technology stack
12+
13+
- **Languages & frameworks**:
14+
- PHP 8.3+
15+
- Symfony 7.3
16+
- PostgreSQL 16.x (via Doctrine ORM 3.x)
17+
- TypeScript
18+
- **Development requirements**:
19+
- Docker
20+
- Symfony CLI
21+
- **Package managers**:
22+
- **PHP**: Composer
23+
- **TypeScript**: NPM
24+
- **Frontend**: Twig, EasyAdmin 4.x
25+
- **Frontend (JavaScript)**: Webpack Encore, Stimulus
26+
- **Linting**: Rector, PHP-CS-Fixer, PHPStan
27+
- **Testing**: PHPUnit 12.x, Testcontainers
28+
29+
### Coding style
30+
31+
#### PHP
32+
33+
Dirigent follows the [PER coding style][per-coding-style] and the [Symfony coding standards][symfony-coding-standards].
34+
35+
## Running Dirigent locally
36+
37+
### Installation
38+
39+
To run Dirigent locally, follow the [Running from source code][docs-install-source] guide in the documentation,
40+
up to the *Configure services* section.
41+
42+
Additional requirements:
43+
44+
- Symfony binary
45+
- Docker
46+
47+
48+
```shell
49+
# Optionally, copy the example Docker Compose configuration override file
50+
cp compose.override.example.yaml compose.override.yaml
51+
52+
# Install dependencies
53+
composer install
54+
npm install
55+
56+
# Build frontend assets
57+
npm run build # or watch for changes with: npm run watch
58+
59+
# Run services through Docker Compose
60+
docker compose up -d
61+
62+
# Run the Symfony development server
63+
symfony server:start -d
64+
65+
# Create & fill the development database
66+
symfony console doctrine:database:create --if-not-exists
67+
symfony console doctrine:schema:update --force
68+
symfony console doctrine:fixtures:load --no-interaction
69+
```
70+
71+
## Lint & validate the code
72+
73+
```shell
74+
# Run all linting jobs
75+
symfony composer lint
76+
77+
# Individual linters
78+
symfony composer lint:refactor # Rector (automatically applies changes)
79+
symfony composer lint:coding-style # PHP-CS-Fixer (automatically applies changes)
80+
symfony composer lint:static-analysis # PHPStan level 5
81+
symfony composer lint:container # Symfony container validation
82+
symfony composer lint:templates # Twig template validation
83+
```
84+
85+
### Running tests
86+
87+
```shell
88+
# Prepare the Symfony test environment (if the database schema changed)
89+
symfony composer tests:setup
90+
```
91+
92+
```shell
93+
# Run all tests
94+
symfony composer tests
95+
96+
# Run only PHP tests
97+
symfony composer tests:php
98+
symfony composer tests:php:unit
99+
symfony composer tests:php:functional
100+
101+
# Run tests for Docker images
102+
symfony composer tests:docker
103+
symfony composer tests:docker:standalone
104+
```
105+
106+
[codedmonkey-sponsor]: https://github.com/sponsors/codedmonkey
107+
[docs-install-source]: ./docs/installation/source.md
108+
[per-coding-style]: https://www.php-fig.org/per/coding-style/
109+
[symfony-coding-standards]: https://symfony.com/doc/current/contributing/code/standards.html

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ until it's second anniversary. See our [full license][license] for more details.
4040

4141
## Contributing
4242

43-
Feel free to report issues and make suggestions on [GitHub][github-issues] or follow our [contribution guide](contributing.md).
43+
Feel free to report issues and make suggestions on [GitHub][github-issues] or follow our [contribution guide](CONTRIBUTING.md).
4444

4545
## About Me
4646

4747
Dirigent is developed by [Coded Monkey][codedmonkey].
4848

4949
[codedmonkey]: https://www.codedmonkey.com
50-
[codedmonkey-sponsor]: https://www.codedmonkey.com/sponsor?project=dirigent
50+
[codedmonkey-sponsor]: https://github.com/sponsors/codedmonkey
5151
[composer]: https://getcomposer.org
5252
[dirigent]: https://dirigent.dev
5353
[docs]: docs/readme.md

composer.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@
144144
"@tests:php:functional"
145145
],
146146
"tests:php:functional": "bin/phpunit tests/FunctionalTests",
147-
"tests:php:unit": "bin/phpunit tests/UnitTests"
147+
"tests:php:unit": "bin/phpunit tests/UnitTests",
148+
"tests:setup": [
149+
"bin/console --env=test doctrine:database:create --if-not-exists",
150+
"bin/console --env=test doctrine:schema:update --force",
151+
"bin/console --env=test doctrine:fixtures:load --no-interaction"
152+
]
148153
},
149154
"scripts-descriptions": {
150155
"build:standalone": "Build the standalone image",
@@ -162,7 +167,8 @@
162167
"tests:docker:standalone": "Run tests in the standalone image",
163168
"tests:php": "Run all PHP tests",
164169
"tests:php:functional": "Run the functional test suite",
165-
"tests:php:unit": "Run the unit test suite"
170+
"tests:php:unit": "Run the unit test suite",
171+
"tests:setup": "Prepare the Symfony test environment"
166172
},
167173
"config": {
168174
"allow-plugins": {

contributing.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)