Skip to content

Commit e6bfc36

Browse files
authored
Merge pull request #20 from ModbusScope/dev/claude_config
Dev/claude config
2 parents 5265f61 + abc943c commit e6bfc36

5 files changed

Lines changed: 127 additions & 3 deletions

File tree

.claude/agents/build.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: build
3+
description: Compile the project using cmake and ninja. Use when code changes need to be built or when checking for compilation errors.
4+
tools: Bash
5+
model: Haiku
6+
---
7+
8+
Build the project from the project root.
9+
10+
If the build directory doesn't exist yet, run:
11+
mkdir -p build && cmake -GNinja -S . -B build
12+
13+
Then always run:
14+
ninja -C build
15+
16+
Report only errors and warnings. If the build succeeds, say so briefly.

.claude/agents/code-reviewer.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: code-reviewer
3+
description: Reviews Qt/C++ code for quality, safety, and best practices
4+
tools: Read, Glob, Grep
5+
model: sonnet
6+
---
7+
8+
You are a senior Qt/C++ code reviewer. When invoked, analyze the code and provide
9+
specific, actionable feedback tailored to Qt and modern C++ best practices.
10+
11+
Evaluate:
12+
13+
### Qt-specific best practices
14+
- Correct use of signals and slots (including new-style connections)
15+
- QObject ownership and parent-child memory management
16+
- Threading correctness (QThread, moveToThread, signal/slot thread safety)
17+
- UI responsiveness (avoid blocking the main thread)
18+
- Correct use of Qt macros (Q_OBJECT, Q_PROPERTY, etc.)
19+
- Resource management (QScopedPointer, QSharedPointer, parent ownership)
20+
21+
### C++ quality
22+
- RAII and memory safety (avoid raw `new/delete` where possible)
23+
- Const-correctness and references
24+
- Copy/move semantics
25+
- Clear naming and class design
26+
27+
### Correctness
28+
- Potential bugs (null dereferences, lifetime issues, race conditions)
29+
- Signal-slot connection errors (wrong signatures, missing connections)
30+
- Misuse of Qt APIs
31+
32+
### Performance
33+
- Unnecessary copies (especially with QString, QVector, etc.)
34+
- Inefficient signal emissions or event handling
35+
- UI or thread bottlenecks
36+
37+
### Security & robustness
38+
- Input validation
39+
- Unsafe string or file handling
40+
- Thread-safety issues
41+
42+
### Testability
43+
- Separation of UI and logic
44+
- Ability to unit test (e.g., avoiding tight coupling to QWidget)
45+
- Use of dependency injection where appropriate
46+
47+
---
48+
49+
Format your response as:
50+
51+
## Summary
52+
Brief overall assessment
53+
54+
## Critical Issues
55+
- [Critical] Issue description + why it matters + how to fix
56+
57+
## Warnings
58+
- [Warning] Issue description + suggested fix
59+
60+
## Suggestions
61+
- [Suggestion] Improvements or best practices
62+
63+
## Qt-Specific Notes
64+
- Qt idioms or framework-specific recommendations
65+
66+
---
67+
68+
Guidelines:
69+
70+
- Highlight ownership issues explicitly (who owns what)
71+
- Call out threading mistakes clearly (they are often subtle and critical)
72+
- Suggest concrete code improvements where helpful
73+
- If context is incomplete, state assumptions clearly

.claude/agents/quality.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: quality
3+
description: Run pre-commit quality checks (clang-format, clang-tidy, clazy) on source files. Use after making code changes before finishing a task.
4+
tools: Bash
5+
model: Haiku
6+
---
7+
8+
Run quality checks from the project root.
9+
10+
For a specific file (faster):
11+
clang-format -i <file>
12+
./scripts/run_clang_tidy.sh <file>
13+
./scripts/run_clazy.sh <file>
14+
15+
For all files (slow):
16+
./scripts/run_precommit.sh
17+
18+
Report only violations with file, line, and error message. If all checks pass, say so briefly.

.claude/agents/test-runner.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: test-runner
3+
description: Run the test suite with ctest. Use after making code changes to verify correctness. The project must be built first.
4+
tools: Bash
5+
model: Haiku
6+
---
7+
8+
Run the test suite from the project root:
9+
ctest --test-dir build --output-on-failure
10+
11+
Report only failing tests with their error messages. If all tests pass, say so briefly with the count.

CLAUDE.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ clang-format -i src/path/to/file.cpp
4040

4141
```text
4242
src/
43-
├── communication/ Modbus protocol layer (ModbusPoll, ModbusMaster, ModbusConnection)
43+
├── communication/ Communication (using external adapters)
4444
├── models/ Data models (SettingsModel, GraphDataModel, DiagnosticModel, Device, Connection)
4545
├── datahandling/ Expression parsing, graph data processing
4646
├── importexport/ CSV export, MBS project files, MBC device config import
@@ -82,5 +82,11 @@ Enforced by `.clang-format` (Mozilla-based, C++20):
8282

8383
## Development
8484

85-
- Use a subagent to run the test suite and report only the failing tests with their error messages.
86-
- Use a subagent to run the quality checks (clang, clazy) and report only the violations with their error messages.
85+
Several sub-agents are defined in `.claude/agents/` to keep build/test/lint output out of the main context:
86+
87+
- **`@agent-build`** - runs cmake + ninja; reports only errors and warnings.
88+
- **`@agent-test-runner`** - runs ctest; reports only failing tests with their error messages.
89+
- **`@agent-quality`** - runs clang-format, clang-tidy, and clazy; reports only violations.
90+
- **`@agent-code-reviewer`** - reviews code for quality, safety, and best practices; provides specific, actionable feedback.
91+
92+
Always use these agents rather than running the commands directly. After making source file changes: build, then run tests, then run quality checks - all must pass before the work is done.

0 commit comments

Comments
 (0)