Skip to content

cli: add --init-skip-if-exists for anonymous dev init#380

Open
nicu-chiciuc wants to merge 1 commit intoget-convex:mainfrom
nicu-chiciuc:init-skip-if-exists
Open

cli: add --init-skip-if-exists for anonymous dev init#380
nicu-chiciuc wants to merge 1 commit intoget-convex:mainfrom
nicu-chiciuc:init-skip-if-exists

Conversation

@nicu-chiciuc
Copy link
Copy Markdown

Summary

  • Adds a new convex dev flag: --init-skip-if-exists
  • Threads this option through:
    • dev CLI options
    • configure flow
    • anonymous local deployment initialization
    • doInitConvexFolder(...)
  • Adds skipIfExists?: boolean support to doInitConvexFolder(...)
  • Adds tests for init behavior in src/cli/lib/codegen.test.ts:
    • preserves existing convex/README.md and convex/tsconfig.json when skipIfExists is enabled
    • still creates missing files
    • preserves existing default overwrite behavior when option is not set

Motivation

In anonymous local dev flows (e.g. CONVEX_AGENT_MODE=anonymous npx convex dev --once), users may want to avoid overwriting existing convex/README.md and convex/tsconfig.json in worktrees.
This change provides an opt-in guard without changing existing defaults.

Usage

CONVEX_AGENT_MODE=anonymous npx convex dev --once --init-skip-if-exists

@nsxdavid
Copy link
Copy Markdown

Very useful!

@ianmacartney ianmacartney requested a review from dowski February 27, 2026 05:45
@dowski
Copy link
Copy Markdown
Contributor

dowski commented Feb 27, 2026

Hey @nicu-chiciuc - thanks for the contribution! This is honestly a good change to make default I think. Basically, unless the CLI is creating the convex/ directory from scratch, it shouldn't touch the tsconfig.json or README.md files in there.

Are you up for stripping down the PR functionality (no more flag) to align with that?

@dowski
Copy link
Copy Markdown
Contributor

dowski commented Feb 27, 2026

This is honestly a good change to make default I think.

And for clarity, I mean however the command is executed (not limited to CONVEX_AGENT_MODE=anonymous).

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.

3 participants