apply
Original:🇺🇸 English
Translated
Use when implementing a Beat change — requires gherkin or proposal artifact to be done first
18installs
Sourcekirkchen/beat
Added on
NPX Install
npx skill4agent add kirkchen/beat applyTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Implement code based on the change artifacts. Supports two modes:
- Gherkin-driven (default): feature files drive implementation and testing
- Proposal-driven: when gherkin is skipped (technical changes), proposal drives testing
<decision_boundary>
Use for:
- Implementing code for a Beat change that has spec artifacts (gherkin or proposal) done
- TDD implementation driven by feature files or proposal risk points
- Resuming implementation of a partially completed change
NOT for:
- Creating spec artifacts like proposal, gherkin, or design.md (use )
/beat:design - Breaking down tasks or creating execution plans (use )
/beat:plan - Verifying implementation completeness (use )
/beat:verify - Exploring ideas or investigating a problem (use )
/beat:explore
Trigger examples:
- "Implement the change" / "Start coding" / "Apply the plan" / "TDD the scenarios"
- Should NOT trigger: "design a feature" / "break down tasks" / "verify the implementation"
</decision_boundary>
<HARD-GATE>
Before any code changes: you MUST invoke superpowers:using-git-worktrees to verify isolation
(should already exist from design/plan; creates one if not).
In TDD mode: you MUST invoke superpowers:test-driven-development.
Invoke in order: worktrees first (verify), then TDD (discipline).
If a prerequisite skill is unavailable (not installed), continue without it — but NEVER skip
because you judged it unnecessary.
</HARD-GATE>
Prerequisites (invoke before proceeding)
| Superpower | When | Priority |
|---|---|---|
| using-git-worktrees | Verify isolation (should exist from design/plan; creates if not) | MUST |
| test-driven-development | At start, in TDD mode | MUST |
| systematic-debugging | When stuck (3 failed attempts) | SHOULD |
| subagent-driven-development | When tasks.md has multiple independent tasks | SHOULD |
Invoke in order: worktrees first (verify isolation), then TDD (discipline). Debugging and subagent are conditional — only invoke when triggered. If a superpower is unavailable (skill not installed), skip and continue.
Rationalization Prevention
| Thought | Reality |
|---|---|
| "The change is small, I don't need a worktree" | Worktrees protect against contamination. The worktree should already exist from design/plan — verify, don't skip. |
| "I'll write the test after the implementation, same result" | TDD is about design feedback, not just test coverage. Writing tests after loses the design signal. |
| "This is a refactor, TDD doesn't apply" | Refactors need tests most — they prove behavior is preserved. If testing.required is false, TDD is already skipped. |
| "I'll add @covered-by annotations at the end for all scenarios" | Annotations must be added per-scenario immediately after writing the test. Batching them leads to forgetting. |
| "The e2e test setup is too complex, I'll write a unit test instead" | The scenario is tagged @e2e for a reason. If e2e setup is genuinely blocked, announce the blocker and ask — don't silently downgrade. |
| "This @behavior test is obvious, a skeleton is enough" | Every test must be executable. A skeleton that doesn't run is not a test. |
| "These tasks are small, I'll combine them for efficiency" | Each task is bounded for a reason. Merging recreates the oversized-output problem that decomposition solved. One task = one subagent dispatch. |
| "The existing test is roughly correct, no need to update it" | If scenario steps changed, the test must reflect those changes. An old test passing does not mean the new behavior is correct. |
| "I'll create a new test file, it's faster" | If @covered-by already points to an existing test, creating a new file breaks traceability. Update the existing test. |
Red Flags — STOP if you catch yourself:
- Writing implementation code before invoking using-git-worktrees
- Writing implementation code before writing a failing test (in TDD mode)
- Thinking "I'll set up the worktree after this first file"
- Skipping TDD because "the test would be trivial"
- Moving to the next scenario without adding to the .feature file
@covered-by - Skipping e2e test creation because "the e2e framework is complex to set up"
- Writing a test skeleton instead of an executable test
- Thinking "I'll add the annotations at the end after all scenarios are done"
- Dispatching a single subagent for multiple tasks to "save time"
- Creating a new test file for a scenario that already has pointing to an existing test
@covered-by - Modifying scenario steps without updating the corresponding e2e test
Mid-Implementation Triggers (mandatory)
- ADR — hard-to-reverse + surprising + real-trade-off decision not in → write ADR (
design.md)references/adr-format.md - README — module public-interface change → update module README ()
references/architecture-format.md
Run inline as conditions arise. Don't batch.
Process Flow
dot
digraph apply {
"Select change, read artifacts" [shape=box];
"Invoke using-git-worktrees" [shape=box, style=bold];
"testing.required false?" [shape=diamond];
"No-test mode" [shape=box];
"Invoke test-driven-development" [shape=box, style=bold];
"Gherkin done?" [shape=diamond];
"Gherkin-driven" [shape=box];
"Proposal-driven" [shape=box];
"tasks.md exists?" [shape=diamond];
"Has Task N headings?" [shape=diamond];
"Executor mode\nfollow tasks exactly" [shape=box];
"Planner mode\nextract scenarios/criteria" [shape=box];
"Implementation loop" [shape=box];
"All tasks complete" [shape=doublecircle];
"Select change, read artifacts" -> "Invoke using-git-worktrees";
"Invoke using-git-worktrees" -> "testing.required false?";
"testing.required false?" -> "No-test mode" [label="yes"];
"testing.required false?" -> "Invoke test-driven-development" [label="no"];
"No-test mode" -> "Gherkin done?";
"Invoke test-driven-development" -> "Gherkin done?";
"Gherkin done?" -> "Gherkin-driven" [label="yes"];
"Gherkin done?" -> "Proposal-driven" [label="gherkin skipped"];
"Gherkin-driven" -> "tasks.md exists?";
"Proposal-driven" -> "tasks.md exists?";
"tasks.md exists?" -> "Has Task N headings?" [label="yes"];
"tasks.md exists?" -> "Planner mode\nextract scenarios/criteria" [label="no"];
"Has Task N headings?" -> "Executor mode\nfollow tasks exactly" [label="yes"];
"Has Task N headings?" -> "Planner mode\nextract scenarios/criteria" [label="no"];
"Executor mode\nfollow tasks exactly" -> "Implementation loop";
"Planner mode\nextract scenarios/criteria" -> "Implementation loop";
"Implementation loop" -> "All tasks complete";
}Input: Optionally specify a change name. If omitted, infer from context or prompt.
Steps
-
Select the changeIf no name provided:
- Look for directories (excluding
beat/changes/)archive/ - If only one exists, use it (announce: "Using change: <name>")
- If multiple exist, use AskUserQuestion tool to let user select
- Look for
-
Read status.yaml and verify readiness (schema:)
references/status-schema.mdCheck that either:- has
gherkin→ Gherkin-driven modestatus: done - has
gherkinANDstatus: skippedhasproposal→ Proposal-driven modestatus: done
If neither condition is met: "Features or proposal are required before implementation. Runfirst." STOP./beat:design -
Read all artifacts and determine testing modeRead in order:
- (if exists) -- business context and risk points
proposal.md - (all files, if gherkin is done) -- implementation targets
features/*.feature - (if exists) -- technical decisions
design.md - (if exists) -- implementation checklist
tasks.md
Read(if exists, schema:beat/config.yaml).references/config-schema.mdDetermine testing mode:- If → no-test mode: skip TDD cycles for all scenarios, write implementation only
testing.required: false - If is set → use that framework for
testing.behaviorscenarios (skip auto-detection)@behavior - If is set → use that framework for
testing.e2escenarios (skip auto-detection)@e2e - If is set (legacy) → treat as
testing.frameworktesting.behavior - If is absent or
testing→ TDD mode (default): require tests for all scenariostesting.required: true
Determine BDD feature paths (for running e2e tests):- Base: (unchanged features;
beat/features/files are invisible to BDD runners).feature.orig - If has
status.yaml: addgherkin.modified(modified + new features)beat/changes/<name>/features/ - Combine both paths when invoking BDD runner (e.g., )
npx cucumber-js beat/features beat/changes/<name>/features
-
Determine implementation strategyIf tasks.md exists: Use it as the implementation checklist.
- Detailed format (contains headings with Steps): Enter executor mode — follow each step exactly as written, don't re-plan.
### Task N: - Simple format (only checkboxes): Enter planner mode — plan each task's implementation yourself (existing behavior).
- [ ]
If no tasks.md and Gherkin-driven: Extract each Scenario from feature files as a unit of work (planner mode).If no tasks.md and Proposal-driven: Extract success criteria and risk points from proposal.md as units of work (planner mode). - Detailed format (contains
-
Show implementation overview
## Implementing: <change-name> ### Drive mode: gherkin-driven / proposal-driven ### Execution mode: executor / planner ### Tasks/Scenarios to implement: 1. [source] <name> 2. [source] <name> ... -
Implement (loop)For each task (from tasks.md) or scenario (from features) or risk point (from proposal):a. Announce: "Working on: <description>"b. Write automated test first (TDD mode only):
- Skip this step if no-test mode
- The test framework: use or
testing.behaviorfrom config (depending on scenario tag), or detect from codebasetesting.e2e
Generate vs Update (seefor details):references/testing-conventions.md- present + test file exists → Update: modify the existing test to reflect new scenario steps
@covered-by - present + test file missing → Generate + WARNING (stale annotation)
@covered-by - absent → Generate: create new test (existing flow)
@covered-by
Forscenarios (Gherkin-driven):@e2e- Generate (or update) e2e test or step definitions using framework from config, or auto-detect from codebase
testing.e2e - If the project uses a BDD runner (Cucumber, pytest-bdd, etc.), generate step definitions that bind to the .feature file
- If no BDD runner, generate a regular e2e test with /
@featureannotations (same as@scenario)@behavior
Forscenarios (Gherkin-driven):@behavior- Generate a test file (using from config, or auto-detect) with annotation comments:
testing.behavior(Use the project language's comment syntax:@feature: <feature-filename>.feature @scenario: <exact scenario name>for JS/TS/Java/C#,//for Python/Ruby, etc.)# - After writing the test, update the .feature file with a annotation (placed between the tag and the scenario line):
@covered-bygherkin@behavior @happy-path # @covered-by: <relative path to test file> Scenario: <name>
For proposal-driven units:- Generate test files covering the risk point using the project's test framework
- No annotation conventions needed (no features to link to)
For pytest-bdd projects: the decorator serves as the annotation — no separate
@scenario/# @featurecomments needed (see# @scenario).references/testing-conventions.md
Follow the conventions infor annotation format, e2e test style, and Generate vs Update path.references/testing-conventions.mdc. Write implementation code:- Follow design.md decisions if available
- Keep changes minimal and focused on the scenario
- In no-test mode: still write implementation, just without preceding test
d. If using tasks.md: Mark task complete->- [ ]- [x]e. Continue to nextf. Scenario completion checklist (verify before moving to next scenario):Forscenarios (TDD mode):@e2e- E2e test or step definition exists and is executable
- Test references the scenario (/
@featureannotations or BDD binding)@scenario - annotation added to .feature file (between tag and Scenario line)
# @covered-by: <path>
Forscenarios (TDD mode):@behavior- Test file exists with and
@featurecomments@scenario - annotation added to .feature file (between tag and Scenario line)
# @covered-by: <path> - Test is executable (not a skeleton)
For all scenarios:- Implementation code handles the scenario's behavior
- Task checkbox marked complete (if using tasks.md)
Do NOT move to the next scenario until all applicable items are checked.Pause if:- Task/scenario is unclear -> ask for clarification
- Implementation reveals design issue -> suggest updating artifacts
- Error or blocker -> report and wait
-
E2E regression check (after all scenarios implemented)Ifscenarios exist and
@e2eis configured (or auto-detected):testing.e2e- Run the full e2e test suite using the combined BDD feature paths
- If any failures → report and pause. Do NOT advance to verify phase.
- All passing → continue to completion.
Skip if noscenarios or no-test mode.@e2e -
On completion or pause, show statusIf all done: updatephase to
status.yamlverify## Implementation Complete **Change:** <name> **Scenarios:** N/N implemented with tests Suggested next steps: - `/beat:verify` -- validate implementation against artifacts - `/beat:archive` -- sync features and archive the change
Testing Rule: Conditional TDD
In TDD mode (default when is true or unset):
testing.required- For every Scenario in every .feature file: there MUST be a corresponding automated test
- scenarios → e2e test or step definitions (using project's e2e framework)
@e2e - scenarios → test with
@behavior/@featureannotations +@scenariocomment in .feature@covered-by - The test MUST be executable (not just a skeleton)
- The test framework: (for @behavior) or
testing.behavior(for @e2e) from config, or auto-detect from codebasetesting.e2e - If the project has a BDD runner (Cucumber, pytest-bdd, etc.), generate step definitions that bind directly to .feature files
In proposal-driven mode (gherkin skipped):
- Tests are driven by proposal.md success criteria and risk points
- Each risk point should have corresponding test coverage
- No annotation conventions (no features to link to)
In no-test mode ():
testing.required: false- Tests are not required. Implementation code is written directly.
- Developers may still write tests voluntarily using /
testing.behaviorif specified.testing.e2e
Guardrails
- Never implement without reading artifacts first (features in gherkin-driven, proposal in proposal-driven)
- In TDD mode: always write test before implementation
- For scenarios: always add
@behaviorannotation to .feature after writing the test@covered-by - For scenarios: always add
@behavior/@featureannotations in the test file@scenario - Keep each change scoped to one scenario/task
- Update task checkbox immediately after completing each task
- Pause on errors, blockers, or unclear requirements -- don't guess
- If implementation reveals issues with features/design, suggest updating artifacts