Skip to content

fix(scaffold-create): auto-cleanup downloaded scaffold after create (#157)#158

Draft
ericelliott wants to merge 3 commits intomainfrom
cursor/aidd-fix-no-issues-fc35
Draft

fix(scaffold-create): auto-cleanup downloaded scaffold after create (#157)#158
ericelliott wants to merge 3 commits intomainfrom
cursor/aidd-fix-no-issues-fc35

Conversation

@ericelliott
Copy link
Collaborator

@ericelliott ericelliott commented Mar 17, 2026

Problem

Running npx aidd create <url> a second time failed with a destination-conflict error because ~/.aidd/scaffold/ was left on disk. The previous code returned a cleanupTip hint but never ran cleanup automatically.

Additionally, there was an asymmetry in the public CLI: no way to opt out of cleanup (no --keep flag), yet scaffold-cleanup existed as a public subcommand.

Fixes #157.

Solution

Commit 1 — auto-cleanup on success

runCreate now automatically calls scaffoldCleanup() after a successful runManifest when paths.downloaded === true. Named and file:// sources are unaffected.

Commit 2 — move cleanup to finally; remove public subcommand

  • Cleanup is now in a try/finally block so it fires on both success and failure (e.g. a manifest step throws). This eliminates the last scenario where ~/.aidd/scaffold/ could be orphaned.
  • scaffold-cleanup subcommand removed from the CLI. With no --keep flag, a public cleanup command is pointless and confusing. scaffoldCleanup remains an internal function.
  • scaffold-resolver.js error message updated to say "delete manually" instead of "run npx aidd scaffold-cleanup".

Changed files

File Change
lib/scaffold-create.js scaffoldCleanupFn in try/finally; updated JSDoc
lib/scaffold-commands.js Removed scaffold-cleanup subcommand and its import
lib/scaffold-resolver.js Updated destination-conflict error message
lib/scaffold-create.test.js Added tests: cleanup-on-success, cleanup-on-failure, no cleanup for non-downloaded
lib/scaffold-commands.test.js Removed scaffold-cleanup from expected command list; dropped its vi.mock
lib/scaffold-resolver.test.js Updated mentionsCleanupmentionsDelete assertion
bin/create-e2e.test.js Removed aidd scaffold-cleanup describe block; updated success-message test
docs/scaffold-authoring.md Documented automatic cleanup behaviour
tasks/npx-aidd-create-epic.md Updated requirements
tasks/scaffold-review-followups-epic.md Updated error-message requirement
plan.md Updated task count

Tests

  • 349 unit tests pass (+1 new test for cleanup-on-failure)
  • 45 e2e tests pass
  • Lint and type-check clean
Open in Web Open in Cursor 

…eate

After a successful `npx aidd create <url>`, the downloaded scaffold
files in ~/.aidd/scaffold/ are now automatically removed via
scaffoldCleanup(). This prevents the destination-conflict error on
subsequent runs.

Named and file:// scaffolds are unaffected — cleanup only fires when
paths.downloaded === true (HTTP/HTTPS downloads).

Closes #157
…-cleanup CLI

Cleanup of downloaded scaffold files now happens unconditionally in a
try/finally block inside runCreate, covering both success and failure
paths. Previously it only ran on success, leaving ~/.aidd/scaffold/
behind on a failed manifest run.

The scaffold-cleanup subcommand has been removed from the public CLI.
There is no way to opt out of auto-cleanup (no --keep flag), so a
public cleanup command was asymmetric. scaffoldCleanup remains an
internal function used by runCreate.

Changes:
- scaffold-create.js: wrap runManifest in try/finally; call
  scaffoldCleanupFn() in finally when paths.downloaded
- scaffold-commands.js: remove scaffold-cleanup subcommand + import
- scaffold-resolver.js: update destination-conflict error message to
  say "delete manually" instead of "run scaffold-cleanup"
- scaffold-create.test.js: add test for cleanup-on-failure
- scaffold-commands.test.js: remove scaffold-cleanup from expected
  command list; drop its vi.mock
- scaffold-resolver.test.js: update mentionsCleanup -> mentionsDelete
- create-e2e.test.js: remove scaffold-cleanup describe block; update
  "does not suggest" test to check success message instead
- docs/scaffold-authoring.md: document automatic cleanup behaviour
- tasks/, plan.md: update epic and plan to reflect removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We should auto cleanup after npx aidd create <url>

2 participants