Skip to content

Commit 2671238

Browse files
chore: track Claude Code project config and reference docs
- .gitignore: add .kotlin/ scratch dir + .claude/settings.local.json (local user permission overrides should not be shared) - .claude/: hooks (post-tool-call, pre-bash, on-stop), settings.json (project hook config), skills (api-feature, code-review, debugging, pr-artifacts), and adr command — all project-shared - 08-kore-runtime.md: original feature spec referenced from CLAUDE.md - claude-code-harness-engineering-guide-v2.md: harness engineering reference also cited from CLAUDE.md - .planning/config.json: persist _auto_chain_active flag Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent be3a7f1 commit 2671238

14 files changed

Lines changed: 1311 additions & 1 deletion

File tree

.claude/commands/adr.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
You are creating an Architecture Decision Record for the kore-runtime Kotlin/Spring WebFlux project.
2+
3+
1. Use a sub-agent to research the decision context by reading the relevant code,
4+
existing ADRs in docs/adr/, and the current GH issue if one is open.
5+
2. Number the new ADR: `ls docs/adr/ | sort | tail -1` -> increment NNNN.
6+
3. Use the template at `.claude/skills/pr-artifacts/adr_template.md`.
7+
4. Write the ADR in a sub-agent with a clean context — do not inline it.
8+
5. Output the final file path and first 10 lines as confirmation.
9+
6. Create a GH issue for discussion: `gh issue create --label adr --title "ADR NNNN: title"`

.claude/hooks/on-stop.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
cd "$CLAUDE_PROJECT_DIR" || exit 0
3+
4+
# Skip if no Gradle wrapper yet (project not scaffolded)
5+
[ -f "./gradlew" ] || exit 0
6+
7+
# 1. Run fast unit tests silently — surface errors only
8+
TEST_OUTPUT=$(./gradlew test -q 2>&1)
9+
if [ $? -ne 0 ]; then
10+
echo "Unit tests failed:" >&2
11+
echo "$TEST_OUTPUT" >&2
12+
exit 2
13+
fi
14+
15+
# 2. Coverage check — re-engage agent if it drops
16+
COVERAGE=$(./gradlew jacocoTestCoverageVerification -q 2>&1)
17+
if [ $? -ne 0 ]; then
18+
echo "Coverage dropped below threshold. Increase test coverage before finishing." >&2
19+
exit 2
20+
fi
21+
22+
# 3. Verify GH issue is linked on feature branches
23+
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
24+
if [[ "$BRANCH" == feature/* ]] || [[ "$BRANCH" == feat/* ]]; then
25+
ISSUE_LINKED=$(git log origin/main..HEAD --format="%s %b" 2>/dev/null | grep -cE "#[0-9]+")
26+
if [ "$ISSUE_LINKED" -eq 0 ]; then
27+
echo "No GitHub issue linked in commit history. Add before finishing." >&2
28+
exit 2
29+
fi
30+
31+
# Create draft PR if it doesn't exist
32+
gh pr create --fill --draft 2>/dev/null || true
33+
fi

.claude/hooks/post-tool-call.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
cd "$CLAUDE_PROJECT_DIR" || exit 0
3+
4+
# Skip if no Gradle wrapper yet (project not scaffolded)
5+
[ -f "./gradlew" ] || exit 0
6+
7+
# Run ktlint + compile in parallel, silent on success
8+
OUTPUT=$(./gradlew ktlintCheck compileKotlin -q 2>&1)
9+
10+
if [ $? -ne 0 ]; then
11+
echo "Build/lint errors:" >&2
12+
echo "$OUTPUT" >&2
13+
exit 2 # exit 2 = re-engage agent to fix errors before finishing
14+
fi
15+
16+
# SUCCESS: completely silent — nothing added to context

.claude/hooks/pre-bash.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
COMMAND="$CLAUDE_TOOL_INPUT_COMMAND"
3+
4+
# Block direct Flyway migration runs
5+
if echo "$COMMAND" | grep -qE "flyway:migrate|flywayMigrate|migrate --env"; then
6+
echo "ERROR: Do not run migrations directly. Ask the user to run them." >&2
7+
exit 1
8+
fi
9+
10+
# Block production deployments
11+
if echo "$COMMAND" | grep -qE "deploy.*(prod|production)|helm upgrade.*prod"; then
12+
echo "ERROR: Production deployments require explicit human approval." >&2
13+
exit 1
14+
fi
15+
16+
# Block force-push
17+
if echo "$COMMAND" | grep -q "git push --force\|git push -f"; then
18+
echo "ERROR: Force push is not allowed. Use --force-with-lease and confirm with user." >&2
19+
exit 1
20+
fi
21+
22+
# Block dropping databases
23+
if echo "$COMMAND" | grep -qiE "drop (database|schema)"; then
24+
echo "ERROR: Dropping databases requires human confirmation." >&2
25+
exit 1
26+
fi

.claude/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"hooks": {
3+
"postToolCall": [
4+
{
5+
"matcher": "Write|Edit",
6+
"command": ".claude/hooks/post-tool-call.sh"
7+
}
8+
],
9+
"preBash": [
10+
{
11+
"command": ".claude/hooks/pre-bash.sh"
12+
}
13+
],
14+
"stop": [
15+
{
16+
"command": ".claude/hooks/on-stop.sh"
17+
}
18+
]
19+
}
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# API Feature Development Skill
2+
Follow this 7-phase workflow for new features in kore-runtime.
3+
4+
## Phases
5+
1. **Discovery** — read existing similar modules; identify patterns in hexagonal architecture
6+
2. **Exploration** — use a sub-agent to trace the relevant port/adapter boundaries
7+
3. **Clarifying Questions** — surface ambiguities before writing any code
8+
4. **Architecture** — define contracts (port interfaces, sealed result types, DTOs)
9+
-> If decision has architectural impact: create ADR draft in docs/adr/
10+
5. **Implementation** — port interface -> adapter -> service -> tests for each layer
11+
6. **Quality Review** — run `./gradlew ktlintCheck test` and fix all issues
12+
7. **PR Preparation** — write changelog entry, update KDoc, run /skill pr-artifacts
13+
14+
## Kore-Runtime Patterns
15+
- All LLM backends implement the same port interface
16+
- AgentResult sealed class: Success | BudgetExceeded | ToolError | LLMError
17+
- Event bus is pluggable: Kotlin Flows default, Kafka opt-in
18+
- Every LLM call and tool use gets an OpenTelemetry span
19+
- Coroutines everywhere — no blocking calls
20+
21+
## Response Template
22+
After each phase, state: what was done, what was decided, what's next.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Code Review Skill
2+
You are performing a code review for the kore-runtime Kotlin/Spring WebFlux codebase.
3+
4+
## Review Checklist
5+
- [ ] Coroutine usage correct (no blocking calls in suspend context)
6+
- [ ] Error handling — sealed classes (AgentResult), no silent catches, proper logging
7+
- [ ] Test coverage — new public functions have tests
8+
- [ ] No hardcoded configuration — use @ConfigurationProperties or application.yml
9+
- [ ] No `var` — always `val`, refactor if mutation seems needed
10+
- [ ] No `!!` without a comment explaining why it's safe
11+
- [ ] Hexagonal architecture respected — LLM backends, storage, event bus are ports/adapters
12+
- [ ] No Thread.sleep() or raw threads — use coroutines
13+
- [ ] Function length < 30 lines; complexity reasonable
14+
- [ ] Immutable data classes for value objects
15+
- [ ] No credentials or secrets in code
16+
- [ ] KDoc on all public APIs
17+
18+
## Output Format
19+
Return: summary, blocking issues (must fix), suggestions (nice to have).
20+
Cite each issue as `filepath:line — description`.

.claude/skills/debugging/SKILL.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Debugging Skill
2+
You are debugging an issue in the kore-runtime Kotlin/Spring WebFlux codebase.
3+
4+
## Process
5+
1. **Reproduce** — write a failing test that demonstrates the bug
6+
2. **Isolate** — use a sub-agent to trace the call chain from entry point to failure
7+
3. **Hypothesize** — form a single testable hypothesis before changing code
8+
4. **Fix** — make the minimal change that fixes the failing test
9+
5. **Verify** — run `./gradlew test` to confirm fix and no regressions
10+
6. **Document** — add a comment if the bug was non-obvious
11+
12+
## Common kore-runtime Pitfalls
13+
- Blocking call inside a coroutine scope (use withContext(Dispatchers.IO) for blocking I/O)
14+
- Missing suspend modifier on function that calls suspend functions
15+
- MCP protocol message serialization/deserialization mismatch
16+
- Agent loop not breaking on BudgetExceeded result
17+
- OpenTelemetry span not closed on error path
18+
19+
## What NOT to do
20+
- Do not change multiple things at once — one hypothesis, one change, one test
21+
- Do not add try/catch to silence the error — find the root cause
22+
- Do not skip writing the regression test
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# PR Artifacts Skill
2+
You are preparing a pull request for the kore-runtime Kotlin/Spring WebFlux codebase.
3+
Produce ALL of the following before calling /gsd:ship or opening a PR for review.
4+
5+
## 1. GitHub Issue
6+
- Verify the PR is linked to a GH issue: `gh issue view <N>` or create one:
7+
`gh issue create --title "<summary>" --body "..."`
8+
- Set the issue reference in the PR body: "Closes #N"
9+
10+
## 2. ADR (Architecture Decision Record)
11+
Required when the PR introduces or changes:
12+
- A new framework, library, or runtime dependency
13+
- An infrastructure or deployment topology change
14+
- A security or authentication pattern
15+
- A data model or schema decision with long-term impact
16+
- A cross-module contract (MCP protocol, LLM backend interface, event schema)
17+
18+
Not required for: bug fixes, refactors within existing patterns, test additions.
19+
20+
Use the template at `adr_template.md`. File as `docs/adr/NNNN-short-title.md`.
21+
NNNN = next sequential number. Commit with message: `docs(adr): NNNN short title`
22+
23+
## 3. Documentation Update
24+
Update whichever of the following applies:
25+
- `docs/` — API docs, runbooks, architecture diagrams
26+
- `README.md` — setup instructions, environment variables
27+
- KDoc on all public APIs — if public interface changed
28+
- `CHANGELOG.md` — one-line entry under Unreleased: `- <summary>`
29+
30+
## 4. Tests
31+
Verify the following before shipping:
32+
- [ ] Unit tests for every new public function (`*Test.kt` in same package)
33+
- [ ] Integration test for any new endpoint or MCP handler
34+
- [ ] Test names follow: `should <expected behaviour> when <condition>`
35+
- [ ] `./gradlew test` passes silently
36+
- [ ] `./gradlew jacocoTestCoverageVerification` passes (80% minimum)
37+
38+
## 5. Verification Report
39+
Produce a brief checklist in the PR description:
40+
- [ ] All unit tests pass
41+
- [ ] Coverage >= 80%
42+
- [ ] ktlint clean (no new violations)
43+
- [ ] ADR written (or explicitly not required — state why)
44+
- [ ] Docs updated
45+
- [ ] GH issue linked
46+
- [ ] Manual smoke test: describe what you tested and the outcome
47+
48+
## PR Description Template
49+
```
50+
## Summary
51+
[1-2 sentences: what changed and why]
52+
53+
## Changes
54+
- [bullet: concrete change]
55+
- [bullet: concrete change]
56+
57+
## Verification
58+
- [ ] Unit tests pass
59+
- [ ] Coverage >= 80%
60+
- [ ] ktlint clean
61+
- [ ] ADR: docs/adr/NNNN-title.md (or: not required because ...)
62+
- [ ] Docs updated: [which files]
63+
- [ ] Issue: Closes #N
64+
65+
## Manual Testing
66+
[What you ran and what you observed]
67+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NNNN. [Short Title]
2+
3+
Date: YYYY-MM-DD
4+
Status: [Proposed | Accepted | Deprecated | Superseded by NNNN]
5+
6+
## Context
7+
[What is the situation? What problem are we solving? What constraints exist?]
8+
9+
## Decision
10+
[What did we decide to do?]
11+
12+
## Consequences
13+
14+
### Positive
15+
- [benefit]
16+
17+
### Negative / Trade-offs
18+
- [cost or risk]
19+
20+
### Neutral
21+
- [side effect]
22+
23+
## Alternatives Considered
24+
[What else was evaluated and why was it rejected?]

0 commit comments

Comments
 (0)