cli
CLI — `init`
src/data/devsnips/docs/cli/init.md
npx devsnips init creates the DevSnips project context in the current working directory without installing anything. Implementation: cli/src/commands/init.js; tests: cli/test/init.test.js.
Syntax
npx devsnips initNo arguments or options. Requires network access? No — init is fully local.
Behavior
- If both
devsnips/config.jsonanddevsnips/AGENTS.mdalready exist, print "DevSnips project context already initialized." and exit 0 without touching anything (idempotent). - Otherwise:
- create
./devsnips/(if missing); - create
./devsnips/config.jsonif missing —{ "version": 1, "project": {}, "resources": [] }; - create
./devsnips/AGENTS.mdif missing — the default agent instructions; - report which files were created; exit 0.
- create
Expected output
First run:
DevSnips
Initializing DevSnips project context... ✓
Created devsnips/AGENTS.md
Created devsnips/config.json
✓ DevSnips project initialized successfullySubsequent run:
DevSnips
DevSnips project context already initialized.Failure behavior
| Condition | Result |
|---|---|
Existing devsnips/config.json is malformed JSON or not an object |
"✗ Initialization failed" with the parse error; the file is left byte-for-byte untouched; exit 1 |
| Filesystem write failure | "✗ Initialization failed" with the OS error; exit 1 |
A malformed config.json is an error, never silently replaced. Fix or remove the file and re-run.
Filesystem changes
| Change | When |
|---|---|
./devsnips/ directory |
Created if missing |
./devsnips/config.json |
Created only when missing |
./devsnips/AGENTS.md |
Created only when missing — never overwritten once it exists |
Relationship to add
add performs the same initialization automatically on the first successful install, so init is optional. Use it when you want the context (notably the agent instructions file) present before any install. The contracts of the two created files are described in Configuration.
Notes for agents
- Running
initin a project that already has the context is a safe no-op. initnever reports the project's stack;config.json'sprojectobject is CLI-protected and left empty by the CLI itself (the CLI never fabricates project information it cannot know).- After
init, an agent should readdevsnips/AGENTS.mdbefore doing UI work — it carries the adaptation rules and quality checks that govern how installed resources are used in that project.