Lattice Core - User Guide
Everything you need to know about using Lattice Core to keep your code quality high and guide AI assistants correctly.
What Does Lattice Core Do?
Think of Lattice Core as a quality checker that runs in the background. It:
- Checks your code - Runs linting, type checking, tests, and builds
- Guides AI assistants - Creates rules so AI uses the right package versions
- Finds security issues - Scans for exposed secrets and API keys
- Tracks changes - Monitors if your code drifts from standards
- Sets up CI/CD - Generates GitHub Actions workflows
- Shows project health - Displays compliance scores and status
Quick Start
First Time Setup
Just run this in your project directory:
npx latticeaiThis will:
- Ask a few questions about your project
- Set up Lattice configuration
- Generate quality rules for AI assistants
- Add verification scripts to your project
That's it! You're ready to go.
Commands Overview
Getting Started
lattice - Interactive Setup
The easiest way to get started. Just run:
npx latticeaiIt will guide you through setup with questions.
lattice setup - Quick Setup
If you know what you want, use flags:
# For a Next.js projectnpx latticeai setup --projectType nextjs --preset startup# For an Expo projectnpx latticeai setup --projectType expo-eas --preset pro# With integrationsnpx latticeai setup --projectType nextjs --preset pro --billing stripe --analytics posthogOptions:
--projectType- Choosenextjsorexpo-eas--preset- Choosestartup,pro, orenterprise(see Presets below)--preview- See what will change before applying--billing- Payment integration:stripe,paddle, ornone--analytics- Analytics:posthog,mixpanel, ornone--observability- Monitoring:sentry,datadog, ornone--testing- Testing framework:jest,vitest, ornone
Using a Bundle:
npx latticeai setup --bundle nextjs-saasnpx latticeai setup --bundle <url> # Or use a URLAvailable bundles: nextjs-saas, nextjs-landing, nextjs-trpc, expo-mobile, expo-supabase
lattice init - Initialize Configuration Only
Create Lattice configuration without generating the pack:
npx latticeai init --projectType nextjs --preset startupnpx latticeai init --detect # Auto-detect project typenpx latticeai init --force # Overwrite existing configFlags:
--projectType <nextjs|expo-eas>- Framework type--preset <startup|pro|enterprise>- Strictness preset--detect- Auto-detect from package.json--force- Overwrite existing config--billing,--analytics,--observability,--testing- Integration options
lattice generate - Generate Pack
Generate the Lattice pack (rules, configs, workflows) without applying:
npx latticeai generatenpx latticeai generate --output ./custom-packnpx latticeai generate --config ./custom-config.jsonWhat it creates:
.cursor/rules.md- AI assistant instructionsprompts/- Reusable prompt templates.github/workflows/- CI/CD workflows.vscode/tasks.json- Editor integrationpackage.jsonscripts - Verification commands
Flags:
--output <dir>- Output directory (default:./lattice-pack)--config <path>- Custom config file (default:.lattice/config.json)
lattice apply - Apply Pack to Project
Apply a generated pack to your project:
npx latticeai applynpx latticeai apply --pack ./lattice-pack --target .npx latticeai apply --preview # Preview changesnpx latticeai apply --confirm # Show preview and ask for confirmationnpx latticeai apply --force # Reset to baseline (overwrites changes)What it does:
- Merges rules into existing
.cursor/rules.md(preserves your custom sections) - Adds/updates package.json scripts
- Creates CI workflows
- Updates editor configs
Flags:
--pack <dir>- Pack directory (default:./lattice-pack)--target <dir>- Target directory (default:.)--preview- Show what would change without applying--confirm- Show preview and ask for confirmation--force- Reset to baseline (overwrites your changes)
Checking Your Code
lattice verify - Run Quality Checks
This is the command you'll use most often. It runs your linting, type checking, tests, and builds.
# Run all checks for your presetnpx latticeai verify# Run only specific checksnpx latticeai verify --only lint,typecheck# Run all checks (ignore preset)npx latticeai verify --full# Watch mode - runs automatically when files changenpx latticeai verify --watchWhat gets checked:
- startup preset: lint, typecheck
- pro preset: lint, typecheck, test
- enterprise preset: lint, typecheck, test, build
Useful flags:
--only <checks>- Run only specific checks (comma-separated)--full- Run all checks regardless of preset--quality- Run quality checks (Lighthouse, axe accessibility) - Next.js only--watch- Keep running and check on file changes--install- Install dependencies if needed--json- Get results as JSON (for scripts)
lattice verify-rules - Check Rules File
Makes sure your AI assistant rules are up to date:
npx latticeai verify-rulesnpx latticeai verify-rules --rules .cursor/rules.md # Custom rules filenpx latticeai verify-rules --stack nextjs # Verify stack matchesFlags:
--rules <path>- Custom rules file path (default:.cursor/rules.md)--stack <stack>- Expected stack (nextjs, expo, etc.)
lattice release-check - Pre-Launch Checklist
Before releasing, run this to make sure everything is ready:
npx latticeai release-checknpx latticeai release-check --fix # Auto-fix what it canChecks for:
- Documentation (README, CHANGELOG)
- Environment variables documented
- No exposed secrets
- All tests passing
- Version numbers updated
Security
lattice security-scan / lattice scan - Find Exposed Secrets
Scans your code for accidentally committed API keys, passwords, and other secrets:
# Just scannpx latticeai security-scan# Scan and automatically fix issuesnpx latticeai security-scan --fix# Also check git historynpx latticeai security-scan --scan-git-history# Install a pre-commit hook to prevent secretsnpx latticeai security-scan --install-hook# Get JSON output (for scripts)npx latticeai security-scan --json# Export SARIF format (for CI/CD tools)npx latticeai security-scan --sarif# Export report to filenpx latticeai security-scan --export report.json# Skip .env file validationnpx latticeai security-scan --skip-env-checkWhat it finds:
- API keys (OpenAI, Anthropic, AWS, Stripe, etc.)
- Database passwords and connection strings
- JWT secrets and tokens
- Private keys (PEM format)
- OAuth tokens and client secrets
- Cloud service credentials (Vercel, Netlify, Heroku, etc.)
- Payment service keys (Stripe, PayPal, Square)
- Email service keys (SendGrid, Mailgun, Resend)
- Monitoring keys (Sentry, Datadog, New Relic)
- And 50+ other secret patterns
Severity levels:
- Critical: API keys, passwords, private keys, database connections
- High: Tokens, webhook URLs, service credentials
- Medium: Email addresses in config, potential keys
Auto-fix (--fix):
- Moves secrets to
.env.local - Updates code to use
process.envvariables - Updates
.gitignoreto exclude.envfiles - Validates secret formats before fixing
Export formats:
--json- JSON output for programmatic use--sarif- SARIF format for CI/CD integration (GitHub Security, etc.)--export <path>- Save report to file (JSON or SARIF)
Additional features:
- Validates
.envfiles are properly gitignored - Scans git history for secrets that were committed in the past
- Pre-commit hook prevents committing secrets
- Secret format validation (checks if keys match expected patterns)
Project Status
lattice status - See How You're Doing
Get a quick overview of your project's health:
npx latticeai statusShows:
- Compliance score (0-100%)
- Configuration status
- Rules file status
- Last verification results
- Drift percentage
lattice drift - See What Changed
Check if your Lattice-managed files have been modified:
npx latticeai driftShows:
- Files you've modified
- Files that were deleted
- New files added
To reset to baseline:
npx latticeai apply --forcelattice progress - Track Project Phases
If you have a PROJECT_GUIDE.md with checkboxes, see your progress:
npx latticeai progressRequires PROJECT_GUIDE.md with checkboxes like:
- [x] Phase 1: Setup - [ ] Phase 2: Build features - [ ] Phase 3: Launch
lattice diff - See Changes
See what's changed since Lattice last generated files:
npx latticeai diffnpx latticeai diff --json # JSON outputConfiguration
lattice config show - View Settings
See your current Lattice configuration:
npx latticeai config shownpx latticeai config show --json # JSON formatlattice rules explain - Understand Rules File
Get an explanation of what your .cursor/rules.md file does:
npx latticeai rules explainUpdates
lattice check - Check for Updates
See if a new version of Lattice is available:
npx latticeai checklattice update - Update Lattice
Update your Lattice rules to the latest version:
npx latticeai updatenpx latticeai update --preview # Preview changes firstThis preserves your custom changes while updating Lattice-generated content.
Bundle Management
lattice bundle update - Check Bundle Version
See if your Lattice bundle is up to date:
npx latticeai bundle updatelattice bundle diff - Preview Bundle Changes
See what would change if you regenerated:
npx latticeai bundle difflattice bundle rollback - Undo Changes
Revert to a previous bundle version (if backup exists):
npx latticeai bundle rollbackCI/CD
lattice ci - Generate CI Workflow
Create a GitHub Actions or GitLab CI workflow:
# GitHub Actions (default)npx latticeai ci# GitLab CInpx latticeai ci --provider gitlab# Preview without writingnpx latticeai ci --dry-runCreates workflows that run lint, typecheck, test, and build on every push.
Advanced Commands
These commands are used internally by setup, but you can use them directly if needed:
See lattice generate and lattice apply above in the "Getting Started" section.
Utilities
lattice doctor - Fix Common Issues
Check your environment and fix common problems:
# Just checknpx latticeai doctor# Check and fix automaticallynpx latticeai doctor --fix# Preview fixes without applyingnpx latticeai doctor --fix --dry-runChecks:
- Node.js and npm versions
- Git setup
- Missing scripts in package.json
- Missing
.gitignore - TypeScript configuration
lattice completions - Shell Autocomplete
Get tab completion for Lattice commands:
# Basheval "$(lattice completions bash)"# Add to ~/.bashrc# Zsheval "$(lattice completions zsh)"# Add to ~/.zshrc# Fishlattice completions fish > ~/.config/fish/completions/lattice.fish# PowerShellInvoke-Expression (lattice completions powershell | Out-String)# Add to $PROFILEPresets Explained
Lattice has three strictness levels:
startup (Recommended for Most)
Light and fast - Good for MVPs and side projects
- Checks: lint, typecheck
- Fast feedback
- Minimal overhead
pro
Balanced - Good for production apps
- Checks: lint, typecheck, test
- Ensures you have tests
- Good for freelance work
enterprise
Comprehensive - For critical systems
- Checks: lint, typecheck, test, build
- Full build verification
- Best for large teams
What Gets Created
After running lattice setup, you'll have:
your-project/ ├── .lattice/ │ ├── config.json # Your Lattice settings │ ├── manifest.json # What Lattice generated │ └── compliance.json # Verification history ├── .cursor/ │ └── rules.md # Rules for AI assistants ├── prompts/ # Reusable prompt templates │ ├── 01-feature-implementation.md │ ├── 02-bug-fix.md │ ├── 03-safe-refactor.md │ ├── 04-test-first.md │ ├── 05-ui-polish.md │ └── 06-security-review.md ├── .github/ │ └── workflows/ │ └── ci.yml # CI workflow ├── .vscode/ │ └── tasks.json # Editor tasks └── package.json # Updated with verify scripts
Common Workflows
Daily Development
# Before committingnpx latticeai verify# While coding (runs automatically on save)npx latticeai verify --watch# Run quality checks (Lighthouse, accessibility)npx latticeai verify --quality# Check for security issuesnpx latticeai security-scanBefore Releasing
# Full production checknpx latticeai release-check --fix# Make sure everything passesnpx latticeai verify --full# Check if anything driftednpx latticeai driftUpdating Lattice
# Check for updatesnpx latticeai check# See what would changenpx latticeai update --preview# Apply updatenpx latticeai updateSetting Up CI/CD
# Generate GitHub Actions workflownpx latticeai ci# Or GitLab CInpx latticeai ci --provider gitlabHow It Works with AI Assistants
Cursor
Lattice creates .cursor/rules.md that tells Cursor:
- What package versions to use
- Your project structure
- How to verify code quality
- Framework-specific patterns
Cursor automatically reads and follows these rules.
Claude Code
Lattice also creates CLAUDE.md for Claude Code compatibility.
Troubleshooting
"No Lattice configuration found"
Run setup:
npx latticeai setup"Verify failed - missing scripts"
Fix automatically:
npx latticeai doctor --fix"Drift detected"
See what changed:
npx latticeai driftReset to baseline:
npx latticeai apply --force"Security scan found secrets"
Auto-fix:
npx latticeai security-scan --fixThen:
- Review the changes
- Update your deployment environment variables
- Rotate any exposed secrets
Tips & Tricks
Custom Rules
You can add your own rules to .cursor/rules.md. Lattice won't overwrite anything outside the <!-- LATTICE:START --> and <!-- LATTICE:END --> markers:
<!-- LATTICE:START ... --> ... Lattice-generated content ... <!-- LATTICE:END --> ## My Custom Rules Add your own rules here - they'll be preserved!
Customizing Bundles
- Run
lattice generateto create a pack - Modify files in
lattice-pack/ - Apply with
lattice apply
Viewing Compliance History
Check .lattice/compliance.json or run lattice status to see your verification history and compliance scores.
Getting Help
- Run
lattice helpfor command overview - Run
lattice <command> --helpfor specific command help - Check the
docs/directory for more documentation
Summary
Lattice Core is free and helps you:
- Keep code quality high
- Guide AI assistants correctly
- Find security issues
- Track project health
- Set up CI/CD easily
Just run npx latticeai to get started!