Skip to content

Commit ce676fd

Browse files
authored
Revise CLAUDE.md for clarity and new sections (#71)
Updated CLAUDE.md to refine guidance for editing and add sections on known gotchas and anti-patterns.
1 parent 1c03e9b commit ce676fd

1 file changed

Lines changed: 10 additions & 88 deletions

File tree

CLAUDE.md

Lines changed: 10 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,18 @@
11
# CLAUDE.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This file captures only what cannot be inferred from the codebase itself.
44

5-
## Project Overview
5+
## Rules for editing this file
66

7-
This is **xemantic-kotlin-test**, an AX-first (AI/Agent Experience) Kotlin multiplatform testing library with power-assert compatible assertions DSL. Designed to minimize cognitive load for LLMs—meaning concise, semi-natural language flow that produces clear, diff-based error output when assertions fail. Supports JVM, JS, Native (macOS, iOS, Linux, Windows), and WASM.
7+
Both developers and AI agents are expected to add entries as they encounter surprises.
88

9-
## Core Architecture
9+
- **Add an entry** when you encounter something unexpected: a build quirk, a non-obvious constraint, a dependency gotcha, or any behavior that would surprise the next agent or developer.
10+
- **Add an entry** when a developer flags an anti-pattern produced by AI — describe the anti-pattern and the preferred alternative.
11+
- **Do not** add codebase overviews, directory listings, or anything discoverable by reading the source.
12+
- Keep entries concise: one line per lesson, grouped under a heading if a theme emerges.
1013

11-
### Source Structure
12-
- `src/commonMain/kotlin/` - Core multiplatform code:
13-
- `Assertions.kt` - Power-assert DSL: `assert`, `should`, `be`, `have`
14-
- `SameAs.kt` - String comparison with unified diff output (Myers' algorithm)
15-
- `SameAsJson.kt` - JSON comparison with automatic prettification
16-
- `TestContext.kt` - Cross-platform environment access (`getEnv`, `gradleRootDir`, `isBrowserPlatform`)
17-
- `coroutines/SuspendShould.kt` - Suspend version of `should` for coroutine tests
18-
- `text/StringFlows.kt` - Flow utilities for testing streaming text
19-
- Platform-specific `expect` implementations in `src/{jvm,js,native,wasmJs,wasmWasi}Main/kotlin/`
14+
## Known gotchas
2015

21-
### Key Assertion Functions
16+
## Anti-patterns to avoid
2217

23-
| Function | Purpose |
24-
|----------|---------|
25-
| `assert(condition)` | Power-assert enabled boolean assertion |
26-
| `obj should { ... }` | Scoped assertions on an object with null check |
27-
| `be<Type>()` | Type assertion with smart cast within `should` block |
28-
| `have(condition)` | Power-assert enabled condition within `should` block |
29-
| `actual sameAs expected` | String equality with unified diff on failure |
30-
| `actual sameAsJson expected` | JSON comparison (prettifies actual, diff on failure) |
31-
32-
## Commands
33-
34-
### Build Commands
35-
```bash
36-
./gradlew build # Full build for all platforms
37-
./gradlew assemble # Assemble artifacts without tests
38-
./gradlew clean # Clean build directory
39-
```
40-
41-
### Testing Commands
42-
```bash
43-
./gradlew allTests # Run tests on all platforms with aggregated report
44-
./gradlew check # Run all verification tasks including tests and API checks
45-
./gradlew jvmTest # Run JVM tests only
46-
./gradlew jsTest # Run JS tests (browser + Node.js)
47-
./gradlew wasmJsTest # Run WASM JS tests
48-
./gradlew macosArm64Test # Run native tests on macOS ARM64 (use macosX64Test for Intel)
49-
```
50-
51-
### Running a Single Test
52-
```bash
53-
./gradlew jvmTest --tests "com.xemantic.kotlin.test.SameAsTest" # Run specific test class
54-
./gradlew jvmTest --tests "com.xemantic.kotlin.test.SameAsTest.test name" # Run specific test method
55-
```
56-
57-
### API Compatibility
58-
```bash
59-
./gradlew apiCheck # Check API compatibility
60-
./gradlew jvmApiCheck # Check JVM API compatibility specifically
61-
./gradlew klibApiCheck # Check KLib API compatibility
62-
```
63-
64-
### Documentation
65-
```bash
66-
./gradlew dokkaGeneratePublicationHtml # Generate API documentation
67-
```
68-
69-
### Publishing
70-
```bash
71-
./gradlew publishToMavenLocal # Publish to local Maven repository
72-
./gradlew publish # Publish all publications
73-
```
74-
75-
### Maintenance
76-
```bash
77-
./gradlew dependencyUpdates # Check for available dependency updates
78-
```
79-
80-
## Power-Assert Configuration
81-
82-
The power-assert plugin is configured for `com.xemantic.kotlin.test.assert` and `com.xemantic.kotlin.test.have`. When adding new assertion functions that should benefit from power-assert's expression breakdown, add them to the `powerAssert.functions` list in `build.gradle.kts`.
83-
84-
## Platform-Specific Notes
85-
86-
- **Environment variables**: Configured in `build.gradle.kts` for JVM/JS/Native; browser tests use `webpack.config.d/env-config.js`
87-
- **Native emulators**: Use `SIMCTL_CHILD_` prefix for environment variables
88-
- **Disabled tests**: `tvosSimulatorArm64Test`, `watchosSimulatorArm64Test` (require Xcode), `wasmWasiNodeTest` (no env var support), `wasmJsBrowserTest` (stale issues)
89-
90-
## Key Dependencies
91-
92-
- `kotlin-test` - Base testing functionality
93-
- `kotlinx-serialization-json` - JSON parsing for `sameAsJson`
94-
- `kotlinx-coroutines-core` - Coroutine support for suspend assertions
95-
- Power-assert plugin - Enhanced assertion messages with expression breakdown
96-
- Binary compatibility validator - API stability checks
18+
- Do not add content to this file that is already discoverable by reading the source or build scripts — that inflates context without adding signal, reducing AI agent task success rates (see [arxiv 2602.11988](https://arxiv.org/abs/2602.11988)).

0 commit comments

Comments
 (0)