@snap/valdi
v1.3.0
Published
Valdi CLI tools for developers
Downloads
669
Keywords
Readme
Valdi CLI
The Valdi CLI tool provides helpful commands for setting up your environment, creating projects, building applications, and managing your Valdi workflow.
For Users
The CLI is published to npm as @snap/valdi:
# Install globally
npm install -g @snap/valdi
# Set up your development environment
valdi dev_setup
# Verify your setup
valdi doctor
# Get help
valdi --helpCreate Your First App
After setting up your environment, create a new Valdi project:
# Create a new directory for your project
mkdir my_valdi_app
cd my_valdi_app
# Initialize the project
valdi bootstrap
# Build and install on iOS
valdi install ios
# Or build and install on Android
valdi install android
# Start hot reload for development
valdi hotreloadNow you can edit your TypeScript files and see changes instantly on your device!
For complete documentation, see:
- Command Line Reference
- Installation Guide
- Troubleshooting — run
valdi doctorto diagnose issues, or ask in GitHub Discussions
Key Commands
valdi dev_setup - Automated environment setup
- Installs required dependencies: Bazelisk, Java JDK 17, Watchman and adb (Homebrew on macOS, your distro's package manager on Linux)
- Configures
PATHandJAVA_HOMEin your shell profile; asks forsudofor package installs and (macOS) the JDK symlink - Sets up shell autocomplete
- The Android SDK/NDK aren't installed; Bazel downloads them during the build
- Requires Node.js 20+ and, on macOS, Xcode 26.5 or 27
valdi doctor - Environment diagnostics
- Validates Node.js, Bazel, Java, Android SDK and adb installations
- Verifies shell autocomplete configuration
- macOS: Validates Xcode installation
- Supports
--frameworkmode for additional checks - Supports
--fixto auto-repair issues - Supports
--jsonfor CI/CD integration
valdi bootstrap - Project initialization
- Creates a new Valdi project in the current directory
- Sets up
MODULE.bazel,.bazelrc,BUILD.bazeland source files, pinned to the latest framework release (override with--valdiVersion=<tag>) - Application templates:
ui_applicationandcli_application - Options:
-y(skip confirmation),-n(project name),-t(application type),-l(local Valdi path),-c(clean directory first). Runvaldi bootstrap --helpfor all options.
valdi install <platform> - Build and install
- Builds and installs app to connected device/simulator, or serves web apps locally
- Platforms:
ios,android,macos,web - Web opens the default browser unless
--no-openis passed
valdi hotreload - Development server
- Enables instant hot reload during development
- Watches for file changes and updates app in milliseconds
valdi debugger - Local debugger web interface
- Starts the browser-based Valdi debugger at
127.0.0.1 - Uses live daemon data from running Valdi targets for view hierarchy, preview, inspector state, snapshots, heap, and runtime logs
- Captures CPU profiles through a separate Hermes debugger connection
- Restricts the server to loopback addresses because debugger snapshots can contain application data
- Prefers port
8765and automatically selects the next available port so multiple local sessions can run at once - Supports
--jsonfor automation-friendly startup output - Supports exact-page Owl/Chromium attachment with
--web-preview-urland--chromium-debugging-port; this emits a temporary first-party DevTools extension directory and an explicitly opted-in preview URL
valdi skills - AI assistant skills
- Installs Valdi context files into Claude Code, Cursor, or GitHub Copilot so AI tools generate correct Valdi code instead of React patterns
valdi skills install— auto-detects installed AI tools and installs all skillsvaldi skills list— show available skills and install status per agentvaldi skills update— re-install already-installed skills from the bundled packagevaldi skills create— scaffold a new skill (run from within the Valdi repo)
Other commands: valdi build <platform> (build without installing), valdi package <platform> (create distributable app), valdi export <platform> (export a library artifact), valdi test (run tests), valdi lint check / valdi lint format (lint and format code), valdi log (stream device logs), valdi projectsync (sync VS Code project and native bindings), valdi completion (shell autocomplete setup). Use valdi <command> --help for options.
For complete command documentation, see Command Line Reference.
Creating New Modules
valdi new_module
# Create module without prompts (specify template to skip the prompt)
valdi new_module my_new_module --skip-checks --template=ui_component
# Help
$ valdi new_module --help
valdi new_module [module-name]
******************************************
Valdi Module Creation Guide
******************************************
Requirements for Valdi module names:
- May contain: A-Z, a-z, 0-9, '-', '_', '.'
- Must start with a letter.
Recommended Directory Structure:
my_application/ # Root directory of your application
├── MODULE.bazel # Bazel module (dependencies)
├── BUILD.bazel # Bazel build
└── modules/
├── module_a/
│ ├── BUILD.bazel
│ ├── android/ # Native Android sources (Kotlin)
│ ├── ios/ # Native iOS sources (Objective-C)
│ ├── macos/ # Native macOS sources (Objective-C)
│ ├── web/ # Web sources (TypeScript, compiled by tsc)
│ ├── cpp/ # Native C++ sources
│ └── src/ # Valdi sources
│ └── ModuleAComponent.tsx
├── module_b/
├── BUILD.bazel
│ ├── res/ # Image and font resources
│ ├── strings/ # Localizable strings
└── src/
└── ModuleBComponent.tsx
For more comprehensive details, refer to the core-module documentation:
https://github.com/Snapchat/Valdi/blob/main/docs/docs/core-module.md
******************************************
Positionals:
module-name Name of the Valdi module.
Options:
--debug Run with debug logging [boolean] [default: false]
--version Show version number [boolean]
--help Show help [boolean]
--skip-checks Skips confirmation prompts. [boolean]
--template Module template to use (skips the prompt). One of: ui_component, polyglot_bridge_module, polyglot_view_module [string]For Contributors
This section is for developers working on the Valdi CLI itself.
Prerequisites
Set your npm registry when working on this module:
npm config set registry https://registry.npmjs.org/Development Setup
Install dependencies:
npm installDevelopment
Run the CLI:
npm run mainPass in command line arguments
npm run main bootstrap -- --confirm-bootstrapBuild JavaScript output to ./dist:
npm run buildDevelop with hot reload:
npm run watch
node ./dist/index.js
node ./dist/index.js bootstrap --confirm-bootstrapShow the help menu:
node ./dist/index.js new_module --helpRun unit tests:
npm testInstall the valdi command locally:
npm run cli:installBootstrap pins and patches
The bootstrap template (.metadata/MODULE.bazel.template) is what valdi
bootstrap uses to wire up a user's app. The generated app is the root
bzlmod module, and it pins the Valdi framework to a published release
(DEFAULT_VALDI_RELEASE_TAG); it fetches @valdi from public GitHub, not
from this checkout.
Two rules follow from that:
A patch the generated app must apply belongs in the app, referenced with a root-local
//label — never@valdi//. bzlmod only honors asingle_version_*override/patch from the root module, so the app (not@valdi) has to carry it; and@valdiresolves to the pinned public release, which may not contain internal-only files. Vendor the patch as a.metadatatemplate asset (seeRULES_PYTHON_PATCH*and thebzl/patches/...block in the template). A@valdi//bzl/patches/...reference fails at bootstrap time withBUILD file not found in @@valdi~and breaks therelease_testCI gate.Only bump the template's framework pins (
DEFAULT_VALDI_RELEASE_TAGand any@valdi-sourced overrides) when you are cutting the release that ships the matching files. Pointing the template at a release that doesn't exist yet produces an app that can't build.
