Write Code
Implement the requested behavior with the smallest coherent change that fits the
existing codebase.
Working Contract
- Inspect the relevant code, tests, repository guidance, and working-tree state
before editing.
- State assumptions that affect behavior. Ask only when a missing decision cannot
be recovered from the codebase or available context.
- Prefer established project patterns, dependencies, and domain language.
- Do not add features, configurability, abstractions, or broad cleanup beyond the
request.
- Preserve unrelated user changes. Every changed line should trace to the
requested behavior or to cleanup caused by that change.
Planning Threshold
Start with the change when the path is clear and the work is narrow. Write a
short plan before editing when the change has dependent steps, unclear
requirements, a wide blast radius, an unfamiliar architecture, or material
security, migration, or rollback risk. The plan should expose decisions and
dependencies, not restate routine work.
Challenge an assumption when repository evidence contradicts it or a simpler
solution meets the same outcome. Do not turn ordinary implementation into a
ceremonial planning exercise.
Implementation Loop
- Define observable success criteria.
- For a bug, reproduce the failure or identify a deterministic failing path.
Read references/debugging.md when the cause is not
already localized.
- Find the narrowest ownership boundary for the change.
- Implement the smallest complete solution.
- Run the most focused relevant test, lint, type, or build check.
- Broaden verification according to blast radius and shared-contract risk.
- Inspect the final diff for accidental churn and report remaining risk.
If reproduction is impractical, explain the substitute evidence used. Do not
claim verification that was not performed.
Tool Routing
- Use
twg for Jira requirements, Confluence designs, historical decisions,
ownership, and cross-repository or company context.
- Use
prflow for direct Bitbucket PR state, review comments, checks, pipelines,
failed logs, and merge readiness.
- Use local
git, rg, and repository-native build tools for source inspection
and local verification.
- Read remote context needed to complete the task. Perform PR, Jira, Confluence,
or pipeline mutations only when the user requested that action.
- Use live CLI help through the owning skill when TWG or PRFlow syntax is
uncertain.
Design
- Prefer the simplest design that satisfies current requirements.
- Choose in this order: extend the existing code, use the standard library or
platform, use an already-approved dependency, then write the smallest new
implementation. Add a dependency only when its benefit justifies its
operational and maintenance cost.
- Add an abstraction only when it removes real duplication or represents an
existing domain boundary.
- Keep functions and modules focused. Avoid flag arguments when separate
operations make behavior clearer.
- Prefer explicit data flow and immutable values where they improve reasoning.
- Isolate side effects at clear boundaries such as adapters, repositories, or
command handlers. Make state changes, I/O, retries, and transactions explicit
and testable.
- Use classes when lifecycle, state, polymorphism, or framework integration makes
them clearer than functions.
- Remove imports, variables, helpers, or tests made obsolete by this change.
Mention unrelated dead code instead of deleting it.
Verification
- Test externally observable behavior and failure modes, not implementation
trivia.
- For shared APIs, schemas, persistence, concurrency, security, or cross-module
changes, check affected callers and run broader tests.
- For narrow internal changes, focused tests are sufficient when the blast
radius is demonstrably small.
- When a check fails, determine whether the change caused it. Do not rewrite
unrelated code merely to make the suite green.
Names And Comments
- Use descriptive, consistent, searchable names without type encodings.
- Replace unexplained magic values with domain names or constants.
- Prefer code that explains itself.
- Comment non-obvious intent, constraints, invariants, or consequences. Remove
restatements and commented-out code introduced by the change.
Commits
Commit only when the user asks. Keep each requested commit logical,
self-contained, and working.
- Use an imperative, capitalized subject of at most 50 characters with no period.
- The subject should complete: "If applied, this commit will ..."
- Add a body when needed, separated by a blank line and wrapped near 72
characters.
- Explain what changed and why. The diff already shows how.
- Split unrelated changes instead of forcing them under one subject.
1---2name: write-code3description: Use when implementing features, fixing bugs, refactoring, or making any requested code change. Guides scoped implementation, explicit side-effect boundaries, focused tests, risk-based verification, company-context discovery through TWG, and Bitbucket PR or CI work through PRFlow.4---56# Write Code78Implement the requested behavior with the smallest coherent change that fits the9existing codebase.1011## Working Contract1213- Inspect the relevant code, tests, repository guidance, and working-tree state14 before editing.15- State assumptions that affect behavior. Ask only when a missing decision cannot16 be recovered from the codebase or available context.17- Prefer established project patterns, dependencies, and domain language.18- Do not add features, configurability, abstractions, or broad cleanup beyond the19 request.20- Preserve unrelated user changes. Every changed line should trace to the21 requested behavior or to cleanup caused by that change.2223## Planning Threshold2425Start with the change when the path is clear and the work is narrow. Write a26short plan before editing when the change has dependent steps, unclear27requirements, a wide blast radius, an unfamiliar architecture, or material28security, migration, or rollback risk. The plan should expose decisions and29dependencies, not restate routine work.3031Challenge an assumption when repository evidence contradicts it or a simpler32solution meets the same outcome. Do not turn ordinary implementation into a33ceremonial planning exercise.3435## Implementation Loop36371. Define observable success criteria.382. For a bug, reproduce the failure or identify a deterministic failing path.39 Read [references/debugging.md](references/debugging.md) when the cause is not40 already localized.413. Find the narrowest ownership boundary for the change.424. Implement the smallest complete solution.435. Run the most focused relevant test, lint, type, or build check.446. Broaden verification according to blast radius and shared-contract risk.457. Inspect the final diff for accidental churn and report remaining risk.4647If reproduction is impractical, explain the substitute evidence used. Do not48claim verification that was not performed.4950## Tool Routing5152- Use `twg` for Jira requirements, Confluence designs, historical decisions,53 ownership, and cross-repository or company context.54- Use `prflow` for direct Bitbucket PR state, review comments, checks, pipelines,55 failed logs, and merge readiness.56- Use local `git`, `rg`, and repository-native build tools for source inspection57 and local verification.58- Read remote context needed to complete the task. Perform PR, Jira, Confluence,59 or pipeline mutations only when the user requested that action.60- Use live CLI help through the owning skill when TWG or PRFlow syntax is61 uncertain.6263## Design6465- Prefer the simplest design that satisfies current requirements.66- Choose in this order: extend the existing code, use the standard library or67 platform, use an already-approved dependency, then write the smallest new68 implementation. Add a dependency only when its benefit justifies its69 operational and maintenance cost.70- Add an abstraction only when it removes real duplication or represents an71 existing domain boundary.72- Keep functions and modules focused. Avoid flag arguments when separate73 operations make behavior clearer.74- Prefer explicit data flow and immutable values where they improve reasoning.75- Isolate side effects at clear boundaries such as adapters, repositories, or76 command handlers. Make state changes, I/O, retries, and transactions explicit77 and testable.78- Use classes when lifecycle, state, polymorphism, or framework integration makes79 them clearer than functions.80- Remove imports, variables, helpers, or tests made obsolete by this change.81 Mention unrelated dead code instead of deleting it.8283## Verification8485- Test externally observable behavior and failure modes, not implementation86 trivia.87- For shared APIs, schemas, persistence, concurrency, security, or cross-module88 changes, check affected callers and run broader tests.89- For narrow internal changes, focused tests are sufficient when the blast90 radius is demonstrably small.91- When a check fails, determine whether the change caused it. Do not rewrite92 unrelated code merely to make the suite green.9394## Names And Comments9596- Use descriptive, consistent, searchable names without type encodings.97- Replace unexplained magic values with domain names or constants.98- Prefer code that explains itself.99- Comment non-obvious intent, constraints, invariants, or consequences. Remove100 restatements and commented-out code introduced by the change.101102## Commits103104Commit only when the user asks. Keep each requested commit logical,105self-contained, and working.106107- Use an imperative, capitalized subject of at most 50 characters with no period.108- The subject should complete: "If applied, this commit will ..."109- Add a body when needed, separated by a blank line and wrapped near 72110 characters.111- Explain what changed and why. The diff already shows how.112- Split unrelated changes instead of forcing them under one subject.