All Insights
February 2026

Sunday Coffee & Code: Turning Existing Architecture Into Refactoring (with Claude Code + Gherkin)

This weekendโ€™s experiment was conceptually simple: ๐˜ค๐˜ข๐˜ฏ ๐˜ ๐˜ถ๐˜ด๐˜ฆ โ€œ๐˜จ๐˜ฐ๐˜ฐ๐˜ฅ ๐˜ฅ๐˜ฆ๐˜ด๐˜ช๐˜จ๐˜ฏโ€ ๐˜ช๐˜ฏ ๐˜ฐ๐˜ฏ๐˜ฆ ๐˜ค๐˜ฐ๐˜ฅ๐˜ฆ๐˜ฃ๐˜ข๐˜ด๐˜ฆ ๐˜ต๐˜ฐ ๐˜ณ๐˜ฆ๐˜ง๐˜ข๐˜ค๐˜ต๐˜ฐ๐˜ณ ๐˜ข ๐˜—๐˜ฐ๐˜Š ๐˜ช๐˜ฏ ๐˜ข๐˜ฏ๐˜ฐ๐˜ต๐˜ฉ๐˜ฆ๐˜ณ ๐˜ค๐˜ฐ๐˜ฅ๐˜ฆ๐˜ฃ๐˜ข๐˜ด๐˜ฆ?

By Steve Harris

This weekendโ€™s experiment was conceptually simple: ๐˜ค๐˜ข๐˜ฏ ๐˜ ๐˜ถ๐˜ด๐˜ฆ โ€œ๐˜จ๐˜ฐ๐˜ฐ๐˜ฅ ๐˜ฅ๐˜ฆ๐˜ด๐˜ช๐˜จ๐˜ฏโ€ ๐˜ช๐˜ฏ ๐˜ฐ๐˜ฏ๐˜ฆ ๐˜ค๐˜ฐ๐˜ฅ๐˜ฆ๐˜ฃ๐˜ข๐˜ด๐˜ฆ ๐˜ต๐˜ฐ ๐˜ณ๐˜ฆ๐˜ง๐˜ข๐˜ค๐˜ต๐˜ฐ๐˜ณ ๐˜ข ๐˜—๐˜ฐ๐˜Š ๐˜ช๐˜ฏ ๐˜ข๐˜ฏ๐˜ฐ๐˜ต๐˜ฉ๐˜ฆ๐˜ณ ๐˜ค๐˜ฐ๐˜ฅ๐˜ฆ๐˜ฃ๐˜ข๐˜ด๐˜ฆ? The short answer is yes, hereโ€™s the approach I took: ๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿญ.ย Prompt Claude Code (Opus 4.6) to extract the key design characteristics (architectural patterns, boundaries, scalability model, UX patterns, and operational behaviours) from a repo I am happy with - all the non-functional stuff.ย Save that analysis in Gherkin requirements syntax (The idea is to use that Gherkin file as a ๐—ฝ๐—ผ๐—ฟ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ฑ๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ฐ๐—ผ๐—ป๐˜๐—ฟ๐—ฎ๐—ฐ๐˜). ๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฎ. Prompt CC, against the destination code-base (which had a PoC Python script and README) to refactor it based on the Gherkin requirements.ย No change to the functionality, just the non-functional pieces. ๐—ช๐—ต๐—ฎ๐˜ ๐—ฐ๐—ฎ๐—บ๐—ฒ ๐—ผ๐˜‚๐˜ ๐—ผ๐—ณ ๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿญ: โ€ข 12 Feature groups covering architecture, orchestration, scalability, security, observability, data, and deployment, e.g. Web and Agent separation, API contract, multi-agent orchestration, job completion etc. โ€ข 61 Gherkin formatted requirements A few examples of the kinds of architecture rules captured: โ€ข The web tier ๐—ผ๐—ป๐—น๐˜† ๐—ฑ๐—ผ๐—ฒ๐˜€ ๐˜‚๐—ฝ๐—น๐—ผ๐—ฎ๐—ฑ / ๐˜€๐˜๐—ฎ๐˜๐˜‚๐˜€ / ๐—ฑ๐—ผ๐˜„๐—ป๐—น๐—ผ๐—ฎ๐—ฑ - it never runs agent logic. โ€ข Web โ†” agents communicate ๐—ผ๐—ป๐—น๐˜† ๐˜ƒ๐—ถ๐—ฎ ๐˜๐—ต๐—ฒ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ and the job runner. โ€ข Job runners ๐˜€๐—ฐ๐—ฎ๐—น๐—ฒ ๐—ต๐—ผ๐—ฟ๐—ถ๐˜‡๐—ผ๐—ป๐˜๐—ฎ๐—น๐—น๐˜†. โ€ข Per-step pipeline ๐—ฝ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฒ๐˜€๐˜€ ๐—ถ๐˜€ ๐˜๐—ฟ๐—ฎ๐—ฐ๐—ธ๐—ฒ๐—ฑ, timed, and queryable. โ€ข Uploads artifacts and ๐—ฒ๐—ป๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒs ๐—ผ๐˜„๐—ป๐—ฒ๐—ฟ๐˜€๐—ต๐—ถ๐—ฝ ๐—ถ๐˜€๐—ผ๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป for safe handling. โ€ข P๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐—ฒ๐˜€ ๐—ฎ๐—ป ๐—ฎ๐˜‚๐—ฑ๐—ถ๐˜ ๐˜๐—ฟ๐—ฎ๐—ถ๐—น thatโ€™s useful when things go sideways. ๐—ข๐—ฏ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ณ๐—ฟ๐—ผ๐—บ ๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฎ: โ€ข Consumed 56% of my Pro plan capacity. โ€ข Took 16 minutes to develop a plan, checklist, generate code and PR. โ€ข Generated 2,892 lines of code. โ€ข Had to be prompted to update documentation, which was fair enough, I didnโ€™t have it in the original prompt. โ€ข With the process down, the refactoring of a small PoC into a multi-agent solution, while maintaining good design would takes less than 45 minutes.ย (๐˜–๐˜ง ๐˜ค๐˜ฐ๐˜ถ๐˜ณ๐˜ด๐˜ฆ ๐˜ธ๐˜ฆ ๐˜ข๐˜ญ๐˜ญ ๐˜ฌ๐˜ฏ๐˜ฐ๐˜ธ ๐˜ต๐˜ฉ๐˜ช๐˜ด ๐˜ฐ๐˜ฏ๐˜ญ๐˜บ ๐˜จ๐˜ฆ๐˜ต๐˜ด ๐˜ถ๐˜ด ๐˜ฐ๐˜ฏ๐˜ฆ ๐˜ด๐˜ต๐˜ฆ๐˜ฑ ๐˜ฐ๐˜ง ๐˜ต๐˜ฉ๐˜ฆ ๐˜ธ๐˜ข๐˜บ ๐˜ต๐˜ฐย ๐˜ฑ๐˜ณ๐˜ฐ๐˜ฅ๐˜ถ๐˜ค๐˜ต๐˜ช๐˜ฐ๐˜ฏ - ๐˜ฃ๐˜ถ๐˜ต ๐˜ช๐˜ตโ€™๐˜ด ๐˜ข ๐˜ฃ๐˜ช๐˜จ ๐˜ด๐˜ต๐˜ฆ๐˜ฑ). Why I like this approach: โ€ขย Itโ€™s ๐—บ๐—ผ๐—ฟ๐—ฒ ๐—ฑ๐˜‚๐—ฟ๐—ฎ๐—ฏ๐—น๐—ฒ than a README that you rely on someone to use. โ€ขย Itโ€™s harder to accidentally violate during a refactor - let CC do it and use itโ€™s own checklist to ๐˜๐—ฟ๐—ฎ๐—ฐ๐—ธ ๐˜๐—ต๐—ฒ ๐˜„๐—ผ๐—ฟ๐—ธ. โ€ขย It makes architecture something you can ๐—ฟ๐—ฒ๐˜ƒ๐—ถ๐—ฒ๐˜„ ๐—ฎ๐—ป๐—ฑ ๐—ฒ๐—ป๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒ, not just talk about. Next step for me: fire up the code and test it If youโ€™ve tried anything similar, Iโ€™d love to hear what worked and what didnโ€™t.

Want to Discuss This Topic?

Steve is always happy to have a direct conversation.