Skip to content

[Task]: scaffold.mjs is non-atomic, has no re-run guard, and accepts invalid project names #24

@tonytino

Description

@tonytino

Goal

scripts/scaffold.mjs mutates many files (package.json, README, CHANGELOG, AGENTS.md), deletes files, then deletes itself — with no error handling, no rollback, and no guard against re-running on an already-scaffolded repo. Certain inputs also produce an invalid package.json name. Make scaffolding safe to run and safe to fail.

Acceptance Criteria

  • On startup, if the repo is already scaffolded (e.g. .construct sentinel exists), the script refuses to run with a clear message
  • The mutation phase is wrapped so a mid-run failure reports clearly and does not leave a silently half-customized repo (rollback or at minimum a clear "partial state" error)
  • slugify collapses repeated/leading/trailing hyphens and falls back to a default when the result is empty or otherwise invalid as an npm package name; the project name is validated/escaped before being written into JSON/markdown
  • delete pkg.scripts.scaffold is used rather than relying on JSON.stringify dropping an undefined value
  • Final "next steps" output matches the generated README (.env vs .env.local consistency — see docs accuracy issue)

Context / Files

  • scripts/scaffold.mjs — whole mutation flow (~lines 76-230); slugify ~43-48; .construct write ~135-142 (never read back); pkg.scripts.scaffold = undefined ~84; next-steps mismatch (line 109 README vs line 230 output)
  • Related: Scaffold script uses fragile piped stdin with two readline instances #19 (sequential readline fragility), and the docs-accuracy issue for .env naming

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe:humanHuman must approve before the agent begins worksize:m2–4 hrs, touches multiple filesstatus:readyScoped and ready for an agent to claimtype:bugSomething is broken

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions