Skip to content

bug: --dry-run creates the target directory #206

Description

@griffinwork40

Problem

npx aidd <target> --dry-run creates <target> on disk even though the dry-run is supposed to be a preview only.

In lib/cli-core.js, executeClone calls ensureTargetDir before checking the dryRun flag:

// lib/cli-core.js:222–227
formatHeader({ ...paths, verbose })(logger);

// Ensure target directory exists
await ensureTargetDir(paths)();

if (dryRun) {
  // Dry run: show what would be copied
  ...

ensureTargetDir (lib/cli-core.js:68–80) wraps fs.ensureDir(targetBase), which creates the directory if it doesn't already exist.

Repro

ls /tmp/aidd-dryrun-demo  # does not exist
npx aidd /tmp/aidd-dryrun-demo --dry-run
ls -la /tmp/aidd-dryrun-demo  # directory now exists, empty

Expected

--dry-run should produce no filesystem side effects. The target directory should not be created.

Impact

Minor — only matters when the target directory doesn't already exist. The default invocation (npx aidd .) is unaffected because . already exists. But the behavior surprises users who treat --dry-run as a strict no-op, and the same executeClone path is reused by aidd create, so the surprise compounds in scaffolded flows.

Suggested direction

Move await ensureTargetDir(paths)(); inside the non-dry-run branch (one-line move, ~5 LoC diff including comment update). The dry-run branch only reads from paths.source (the framework's ai/ directory) and prints — it doesn't need the target to exist.

Optionally also gate the source-existence dry-run output on whether paths.targetBase exists, so users see "would create directory" instead of silently assuming it.

Notes

Found during a third-party audit of the install primitive. Citations are against paralleldrive/aidd@57758344 (current main).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions