Context
Near-duplicate file-write helpers exist in four modules:
They all do the same thing — mkdir(parents=True, exist_ok=True) + write_text/write_json — with subtly different overwrite semantics (always overwrite vs skip-if-exists vs append-to-skipped-list). Easy place for bugs to creep in as the surface grows.
Recommendation
Create src/coding_scaffold/io.py with three primitives:
def write_text(path: Path, content: str, *, overwrite: bool = True) -> Path: ...
def write_json(path: Path, payload: object, *, overwrite: bool = True) -> Path: ...
def write_if_absent(path: Path, content: str) -> Path | None: ... # returns None when skipped
Replace all four module-local helpers with these. Update call sites in writers.py, adapters.py, knowledge.py, enablement.py.
Verification
git grep -nE '_write_json|_write_text|_collect_write|_collect\\b' src/ shows no duplicates.
- All 51 tests still pass.
- Adding a new template-writing call site requires importing one of the three helpers, not copying yet another local function.
Carry-over from prior code review (F8).
Context
Near-duplicate file-write helpers exist in four modules:
writers.py:62-71:_write_json,_write_textadapters.py:96-113:_write,_write_json,_collect_writeknowledge.py:58-71:_write,_collectenablement.py: inlinepath.write_text(...)callsThey all do the same thing —
mkdir(parents=True, exist_ok=True)+write_text/write_json— with subtly different overwrite semantics (always overwrite vs skip-if-exists vs append-to-skipped-list). Easy place for bugs to creep in as the surface grows.Recommendation
Create
src/coding_scaffold/io.pywith three primitives:Replace all four module-local helpers with these. Update call sites in
writers.py,adapters.py,knowledge.py,enablement.py.Verification
git grep -nE '_write_json|_write_text|_collect_write|_collect\\b' src/shows no duplicates.Carry-over from prior code review (F8).