一键导入
add-unit-tests
Identify and fill unit test gaps for changed code by analyzing the branch diff. Creates test files following Kotest BehaviorSpec patterns with fakes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Identify and fill unit test gaps for changed code by analyzing the branch diff. Creates test files following Kotest BehaviorSpec patterns with fakes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Convert acceptance criteria, Jira tickets, Gherkin scenarios, PRDs, or any product requirements into a structured spec template. Use when translating PM artifacts into actionable specs for add-*, update, migrate, or remove skills.
Scaffold a complete new feature module with all 6 submodules, source files, tests, fakes, and AGENTS.md. Use when adding an entirely new feature to the app.
Execute cross-cutting migrations — library swaps, pattern changes, API version upgrades, or architecture refactors. Handles phased rollout, coexistence, and rollback planning.
Reverse-engineer a spec from existing code — reconstructs presumed acceptance criteria, data flow, API contracts, UI states, and business rules by reading source, tests, and git history. Use when inheriting undocumented features, onboarding onto unfamiliar code, or preparing for a refactor.
Modify existing feature code across all affected layers — domain models, data, presentation, tests, and fakes. Use when changing behavior, adding fields, or enhancing existing features.
Verification pipeline with three scopes — diff (default, changed modules only), full (whole project lint + unit + arch + builds), and all (every test level + every variant + full assemble). Use after any code change.
| name | add-unit-tests |
| description | Identify and fill unit test gaps for changed code by analyzing the branch diff. Creates test files following Kotest BehaviorSpec patterns with fakes. |
Identify changed/new production classes and create or update their unit tests.
.agents/standards/testing.md.agents/standards/testing-unit.mdThis skill covers Kotest BehaviorSpec unit tests in commonTest/. It does NOT cover:
androidDeviceTest/ — use add-ui-tests)testing/navint-tests/ (JUnit4, require emulator — use add-tests which handles navint-tests awareness)git diff origin/main...HEAD --name-only -- '*.kt'
For each changed file, determine if a test is needed:
| Source File | Expected Test |
|---|---|
features/{name}/impl/domain/*Impl.kt | features/{name}/impl/domain/src/commonTest/.../...ImplTest.kt |
features/{name}/impl/data/*RepositoryImpl.kt | features/{name}/impl/data/src/commonTest/.../...RepositoryImplTest.kt |
features/{name}/impl/presentation/*Presenter.kt | features/{name}/impl/presentation/src/commonTest/.../...PresenterTest.kt |
Check if the test file exists. If it exists, check if new code paths need additional test cases.
Reference: features/order/impl/presentation/src/commonTest/.../OrderPresenterTest.kt
package com.mockdonalds.app.features.{name}.presentation
import com.mockdonalds.app.core.test.TestCenterPostDispatchers
import com.mockdonalds.app.features.{name}.api.navigation.{Feature}Screen
import com.mockdonalds.app.features.{name}.test.FakeGet{Feature}Content
import com.slack.circuit.test.FakeNavigator
import com.slack.circuit.test.presenterTestOf
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
class {Feature}PresenterTest : BehaviorSpec({
Given("a {name} presenter with content available") {
val fakeContent = FakeGet{Feature}Content()
val dispatchers = TestCenterPostDispatchers()
val navigator = FakeNavigator({Feature}Screen)
When("the presenter emits state") {
Then("it should start with empty defaults then populate") {
presenterTestOf(
presentFunction = {
{Feature}Presenter(
navigator = navigator,
get{Feature}Content = fakeContent,
dispatchers = dispatchers,
)
},
) {
val initial = awaitItem()
// assert initial empty state
val state = awaitItem()
// assert populated state
}
}
}
}
})
Reference: features/order/impl/domain/src/commonTest/.../GetOrderContentImplTest.kt
package com.mockdonalds.app.features.{name}.domain
import com.mockdonalds.app.core.test.TestCenterPostDispatchers
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.flow.first
class Get{Feature}ContentImplTest : BehaviorSpec({
Given("a Get{Feature}ContentImpl") {
val repository = // create fake or test instance
val impl = Get{Feature}ContentImpl(repository)
When("observing content") {
Then("it should combine repository flows correctly") {
val result = impl.createObservable(Unit).first()
// assert combined result
}
}
}
})
Reference: features/order/impl/data/src/commonTest/.../OrderRepositoryImplTest.kt
package com.mockdonalds.app.features.{name}.data
import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.flow.first
class {Feature}RepositoryImplTest : BehaviorSpec({
Given("a {Feature}RepositoryImpl") {
val repository = {Feature}RepositoryImpl()
When("fetching data") {
Then("it should return expected values") {
val result = repository.getData().first()
result shouldBe expectedValue
}
}
}
})
If the test requires a fake that doesn't exist yet, create it in features/{name}/test/src/commonMain/:
Reference: features/order/test/src/commonMain/.../FakeGetOrderContent.kt
@ContributesBinding(AppScope::class)
class Fake{Name}(
initial: {ContentType} = DEFAULT,
) : {AbstractClass}() {
private val _content = MutableStateFlow(initial)
override fun createObservable(params: Unit): Flow<{ContentType}> = _content
fun emit(content: {ContentType}) {
_content.value = content
}
companion object {
val DEFAULT = // default test data
}
}
Work is NEVER complete until verification passes. Run the verify skill to validate all changes. It will:
If ANY check fails, fix the issue and re-run. Do not declare the task complete until verification passes.