This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Build for testing:
swift build --package-path . --disable-automatic-resolution - Run tests:
swift test --package-path . --disable-automatic-resolution - Run tests with code coverage: Tests are run through the GitHub Actions workflow using
build_and_test.shfrom DevBuilds - Test specific platform: Use
xcodebuildwith appropriate destination (see.github/workflows/VerifyChanges.yamlfor examples)
- Lint check:
Scripts/lint(runsswift format lint --recursive --strictfrom anywhere) - Format code:
swift format --in-place --recursive Sources/ Tests/ - Manual lint:
swift format lint --recursive --strict Sources/ Tests/ - Swift format configuration: Uses
.swift-formatfile with 4-space indentation and 120 character line length
- Install git hooks:
Scripts/install-git-hooks(installs pre-push hook; supports git worktrees) - Pre-push hook: Automatically runs
Scripts/lintbefore each push
- Build documentation:
swift package generate-documentation - Documentation source:
Sources/DevTesting/Documentation.docc/
RandomValueGenerating Protocol: The central protocol that test suites conform to for generating
repeatable random test data. Uses SeedableRandomNumberGenerator and logs seeds for test
reproducibility.
Three Main Feature Areas:
- Random Value Generation (
Sources/DevTesting/Random Value Generation/): Extensions for generating random values of various types (String, Data, URL, UUID, etc.) with seeded randomness - Collection Generation (
Sources/DevTesting/Collection Generation/): Array extensions for generating collections of random data - Stubbing (
Sources/DevTesting/Stubbing/):StubandThrowingStubclasses for mocking and spying in tests
- Seeded Randomness: All random generation uses
SeedableRandomNumberGeneratorto ensure test reproducibility - Logging Integration: Random seeds are logged using
os.Logger(subsystem: "DevTesting", category: "randomization") - Swift Testing Integration: Designed specifically for Swift Testing framework, not XCTest
- Type Safety: Extensive use of Swift 6 features including typed throws and existential types
- Swift Numerics: Used for
RealModulein tests - Platform Requirements: Version 26 of Apple's OSes
- Swift Version: Requires Swift 6.2 toolchain
- Test Plans: Uses
DevTesting.xctestplanfor organized test execution - Coverage Target: Aims for 99%+ test coverage
- Platform Testing: Tests run on iOS, macOS, tvOS, and watchOS simulators
- CI/CD: GitHub Actions workflow runs builds on iOS, macOS, tvOS, and watchOS
- Always use
whereclauses to declare constraints on generic parameters - Prefer
Float64overDoubleandFloat32overFloat - Always attribute files to the current user, not Claude (e.g., "Created by on mm/dd/yyyy")
- 2 blank lines between major sections including:
- Between the last property declaration and first function declaration
- Between all function/computed property implementations at the same scope level
- Between top-level type declarations (class, struct, enum, protocol, extension)
- Before MARK comments that separate major sections
- 1 blank line for minor separations:
- Between property declarations and nested type definitions
- Between all function definitions in protocols
- After headers in documentation
- After MARK comments that separate major sections
- File endings: All Swift files must end with exactly one blank line
- Full Documentation: All public APIs are documented with Swift DocC
- API Guidelines: Follows Swift API Design Guidelines
- Documentation Comments: Uses triple-slash comments (
///) - Markdown Style: Follow
Documentation/MarkdownStyleGuide.mdfor consistent formatting:- 100 character line length
- 4-space indented code blocks (no fenced blocks)
- 2-space indented bullet lists with alignment
- Consistent terminology (function vs method, type vs class)