Repository navigation
Description
Summary
stellar scaffold clean deletes every account listed under [[development.accounts]] by shelling out to stellar keys rm --force <name> (clean.rs#L148-L191). It has no way of knowing whether Scaffold created that identity. The command is run without --config-dir, so it acts on whichever keystore stellar-cli resolves, normally the global one (~/.config/stellar). The only exception is when XDG_CONFIG_HOME or a loaded .env happens to point somewhere else.
build does not notice name collisions either. If an identity with the dev account's name already exists, it reuses it and only prints An identity with the name '…' already exists. So when a project's dev account shares a name with a key the developer uses elsewhere (alice, admin, deployer, issuer, …), clean permanently deletes that secret key. There is no confirmation: stellar-cli ≥ 26 supports keys rm --force, which skips the prompt (see cmd/soroban-cli/src/commands/keys/rm.rs in stellar-cli v27). The only guard is whether the same name also appears in another environment of the same environments.toml.
The same function has three more problems:
- It uses
returninstead ofcontinue(clean.rs#L157). The first account that is shared with another environment stops cleanup for all remaining accounts. - It depends on the version of the host
stellarbinary. On stellar-cli 25.x the flag doesn't exist and removal fails witherror: unexpected argument '--force' found. - The "not found" filter (
#L122,#L170) doesn't match stellar-cli's real message (no contract found with alias '…'). Every run therefore prints warnings for aliases that simply don't exist.
Repro (isolated keystore, safe)
export XDG_CONFIG_HOME=$(mktemp -d) # isolate the keystore
stellar scaffold init demo --template react -p npm -y && cd demo
stellar keys generate me # stand-in for a key you care about
stellar scaffold clean
ls "$XDG_CONFIG_HOME/stellar/identity" # stellar-cli >= 26: me.toml is goneWith stellar-cli 25.2.0 as the host, the clean step prints this instead:
⚠️ Warning: Failed to remove account me: error: unexpected argument '--force' found
Suggested fix
- Only remove identities that Scaffold itself created, for example by recording them under
target/stellar/…whenhandle_accountsgenerates them. Alternatives: keep dev identities in a project-local config dir, or at minimum prompt before deleting (with--yesfor CI). - Call the embedded stellar-cli library, as
buildalready does, instead of the hoststellarbinary. That removes the version coupling. - Change
returntocontinue. - Match stellar-cli's actual "not found" message, or check that the alias exists before removing it.
Acceptance criteria
cleannever deletes an identity it didn't create, or asks before doing so.- It behaves the same whatever version of
stellaris installed.
Reproduced the stellar-cli 25.2.0 failure with stellar-scaffold-cli 0.0.27. The --force behaviour of stellar-cli ≥ 26 was confirmed from the v27 source.
Activity
zachfedor commentedon Oct 17, 2026
Fixed by #630