fakt
CLAUDE.md67 starsChanged 44 days agoApache-2.0View on GitHub
Kotlin compiler plugin that generates type-safe test fakes at compile time using the @Fake annotation. By default the Gradle plugin runs the compiler in a cacheable FaktGenerateTask worker, and fakes are emitted at the FIR phase. The legacy in-process IR emission is being removed for 1.0 (see #150). v1.0 in progress: the legacy in-process path is being removed. Tracker: #150. Handover: .claude/docs/implementation/v1-sunset-handover.md. 1. Default: FIR emission (FaktGenerateTask -> Gradle Worker -> embedded K2 with Fakt as -Xplugin). FaktFirExtensionRegistrar detects and…
In this repository10 other files it gives its agents.
- bdd-test-runnerSkill
- codegenSkill
- commitSkill
- compilationSkill
- feature-optionSkill
- issue-creatorSkill
- kotlin-api-consultantSkill
- prSkill
- sample-scaffolderSkill
- skill-creatorSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
15 rules. About 0 are common, 9 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 58
Import order: Standard Kotlin -> Third-party -> Project
- Very specific: line 92
Always test with published plugin (publishToMavenLocal), not just project dependencies.
- Very specific: line 93
Use --info flag to debug compiler plugin behavior.
- Distinctive: line 94
Test both single-platform and KMP scenarios.
- Very specific: line 100
Use make commands from project root
- Very specific: line 101
Test with publishToMavenLocal before claiming success
- Distinctive: line 102
Verify generated code compiles without errors
- Very specific: line 103
Put new generation behaviour on the FIR/worker path.
- Distinctive: line 104
Check #150 before starting v1.0 work
- Distinctive: line 106
Write GIVEN-WHEN-THEN tests for all new features
- Distinctive: line 108
Use modular design (analysis -> generation -> output)
- Distinctive: line 114
Use deprecated Kotlin APIs
- Very specific: line 116
Use buildDir (deprecated in Gradle 8+)
- Distinctive: line 120
Use "should" naming or custom test frameworks
- Distinctive: line 122
Use mocks instead of fakes
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md - Fakt Compiler Plugin
Kotlin compiler plugin that generates type-safe test fakes at compile time using the @Fake annotation. By default the Gradle plugin runs the compiler in a cacheable FaktGenerateTask worker, and fakes are emitted at the FIR phase. The legacy in-process IR emission is being removed for 1.0 (see #150).
Architecture
v1.0 in progress: the legacy in-process path is being removed. Tracker: #150. Handover:
.claude/docs/implementation/v1-sunset-handover.md.
- Default: FIR emission (
FaktGenerateTask-> Gradle Worker -> embedded K2 with Fakt as-Xplugin).FaktFirExtensionRegistrardetects and validates@Fake; the FIR checkers emit the fakes (fir/generation/) as declared, cache-correct task outputs. - Legacy: IR emission (
fakt.useExperimentalGenerateTask=false, and the few shapes a task cannot read, such as AGP 9 built-in Kotlin without a hook; all routedLEGACYwith a reason). The plugin runs insidecompileKotlin*;UnifiedFaktIrGenerationExtensiongenerates. Native is not legacy: it runs on the task path. Do not add features here. It is deleted for 1.0.
Both paths share the codegen in codegen-runtime/ (the FakeDeclaration model -> generators).
Output per @Fake interface: FakeXxxImpl class, fakeXxx {} factory function, FakeXxxConfig DSL.
See Architecture doc for details.
Essential Commands
make publish-local # Build + publish to Maven Local (use this for development)
make test-sample # Test KMP sample project
make quick-test # Rebuild plugin + test sample (no cache)
make full-rebuild # Clean + rebuild everything
make debug # Show Fakt-specific compiler logs
make format # Format code (required before commits)
make clean # Clean build artifacts
make help # Show all commandspublish-local automatically compiles, builds shadowJar, creates artifacts, and publishes to ~/.m2/repository. Skips GPG signing locally.
Code Conventions
Naming
@Fake interface UserService
// -> FakeUserServiceImpl (implementation class, same package)
// -> fakeUserService {} (factory function)
// -> FakeUserServiceConfig (configuration DSL)
// Behavior properties (constructor parameters)
// -> private val getUserBehavior: () -> User = { ... }
// -> FakeUserServiceConfig: internal var getUserBehavior: (() -> User)? = nullStyle
- License: Apache 2.0 (managed by Spotless)
- Formatting: ktfmt Google style
- Max line length: 100 characters
- Import order: Standard Kotlin -> Third-party -> Project
Testing Standard
Full spec: Testing Guidelines
Required:
- Vanilla JUnit5 + Kotlin Test only
@TestInstance(TestInstance.Lifecycle.PER_CLASS)always- GIVEN-WHEN-THEN naming (uppercase, BDD style)
runTestfor coroutines- Isolated instances per test (no shared state)
- Fakes instead of mocks
Prohibited:
- "should" naming pattern
- Custom BDD frameworks or matchers (no assertThat, etc.)
- Mocks
- @BeforeEach/@AfterEach
Development Workflow
# 1. Write failing test first (TDD)
# 2. Implement in appropriate module:
# - compiler/.../fir/ for analysis and emission
# - codegen-runtime/ for the generated code shape
# - gradle-plugin/ for task wiring and routing
# 3. Rebuild and test
make publish-local && make test-sample
# 4. Format
make formatAlways test with published plugin (publishToMavenLocal), not just project dependencies.
Use --info flag to debug compiler plugin behavior.
Test both single-platform and KMP scenarios.
Do's and Don'ts
Always
- Use
makecommands from project root - Test with
publishToMavenLocalbefore claiming success - Verify generated code compiles without errors
- Put new generation behaviour on the FIR/worker path; don't extend
ir/ - Check #150 before starting v1.0 work
- Generate code in test source sets only
- Write GIVEN-WHEN-THEN tests for all new features
- Format with
make formatbefore commits - Use modular design (analysis -> generation -> output)
- Clear, actionable error messages with interface name and location
Never
- Skip compilation testing
- Use deprecated Kotlin APIs
- Generate code in main/production source sets
- Use
buildDir(deprecated in Gradle 8+) - Mix FIR and IR phase logic
- Ignore cross-module import resolution
- Hardcode output directories
- Use "should" naming or custom test frameworks
- Share state between tests or use @BeforeEach/@AfterEach
- Use mocks instead of fakes
Key Files
compiler/.../compiler/
├── FaktCompilerPluginRegistrar.kt # Entry point: FIR (+ legacy IR) registration
├── fir/FaktFirExtensionRegistrar.kt # @Fake detection/validation
├── fir/generation/ # FIR emission (default path)
└── ir/generation/UnifiedFaktIrGenerationExtension.kt # LEGACY IR emission (removed in 1.0)
codegen-runtime/.../codegen/
├── analysis/FakeDeclaration.kt # Shared model
└── generator/ # ImplementationGenerator, ConfigurationDslGenerator
gradle-plugin/.../gradle/
├── FaktGradleSubplugin.kt # Routing (cacheCorrectDecision)
├── FaktGenerateTask.kt, worker/FaktCodegenWorkAction.kt
└── android/ # AGP seamsDocumentation
| Document | Path |
| Architecture | .claude/docs/implementation/architecture/ARCHITECTURE.md |
| KMP Strategy | .claude/docs/implementation/architecture/kmp-optimization-strategy.md |
| Testing Guidelines | .claude/docs/development/validation/testing-guidelines.md |
| Kotlin API Reference | .claude/docs/development/kotlin-api-reference.md |
| Kotlin IR API | .claude/docs/development/kotlin-compiler-ir-api.md |
| Troubleshooting | .claude/docs/troubleshooting/common-issues.md |
| v1.0 sunset handover (tracker: #150) | .claude/docs/implementation/v1-sunset-handover.md |
| Public user docs (MkDocs) | docs/ — page tree in the nav: of mkdocs.yml |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

