agentleFS
rsicarellirsicarelli/fakt/CLAUDE.md

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…

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
  1. Distinctive:

    Import order: Standard Kotlin -> Third-party -> Project

    line 58
  2. Very specific:

    Always test with published plugin (publishToMavenLocal), not just project dependencies.

    line 92
  3. Very specific:

    Use --info flag to debug compiler plugin behavior.

    line 93
  4. Distinctive:

    Test both single-platform and KMP scenarios.

    line 94
  5. Very specific:

    Use make commands from project root

    line 100
  6. Very specific:

    Test with publishToMavenLocal before claiming success

    line 101
  7. Distinctive:

    Verify generated code compiles without errors

    line 102
  8. Very specific:

    Put new generation behaviour on the FIR/worker path.

    line 103
  9. Distinctive:

    Check #150 before starting v1.0 work

    line 104
  10. Distinctive:

    Write GIVEN-WHEN-THEN tests for all new features

    line 106
  11. Distinctive:

    Use modular design (analysis -> generation -> output)

    line 108
  12. Distinctive:

    Use deprecated Kotlin APIs

    line 114
  13. Very specific:

    Use buildDir (deprecated in Gradle 8+)

    line 116
  14. Distinctive:

    Use "should" naming or custom test frameworks

    line 120
  15. Distinctive:

    Use mocks instead of fakes

    line 122

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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.

  1. Default: FIR emission (FaktGenerateTask -> Gradle Worker -> embedded K2 with Fakt as -Xplugin). FaktFirExtensionRegistrar detects and validates @Fake; the FIR checkers emit the fakes (fir/generation/) as declared, cache-correct task outputs.
  2. 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 routed LEGACY with a reason). The plugin runs inside compileKotlin*; UnifiedFaktIrGenerationExtension generates. 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 commands

publish-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)? = null

Style

  • 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)
  • runTest for 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 format

Always 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 make commands from project root
  • Test with publishToMavenLocal before 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 format before 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 seams

Documentation

DocumentPath
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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.