xanoscript-lint
v0.0.3
Published
CLI tool for XanoScript LSP - validate .xs files using the XanoScript Language Server
Downloads
169
Maintainers
Readme
XanoScript LSP CLI
A command-line interface for validating XanoScript (.xs) files using the XanoScript Language Server Protocol (LSP) server. Perfect for CI/CD pipelines, pre-commit hooks, and integration with AI CLI coding assistants like Claude Code, Codex, Gemini CLI, and more.
Latest release: v0.0.2 — see CHANGELOG.md for details.
Features
- ✅ Real-time Validation: Uses the official XanoScript LSP server for accurate diagnostics
- ✅ Auto-Discovery: Automatically finds and validates all
.xsfiles in your project - ✅ Multiple Output Formats: Human-readable or JSON output for easy parsing
- ✅ Claude Code Integration: Built-in slash command for AI-assisted error fixing
- ✅ Zero Configuration: Auto-detects the LSP server from your VS Code extension
- ✅ Fast: Validates files in parallel with real-time progress
Claude Code & Skill Setup (Start Here)
- Install the CLI globally (or via
npx) soxs-lintis on your PATH:npm install -g xanoscript-lint # or npx xanoscript-lint --help - In each XanoScript project directory, run:
This links thexs-setup --symlink.claudeskill and/xs-lintcommand to the installed CLI, enabling automatic validation and the Claude slash command. - Inside Claude Code, trigger manual validation with:
You can pass file paths (e.g./xs-lint/xs-lint functions/73_check_output_pii.xs), and the automatic skill will validate after every.xsedit.
Installation
Prerequisites
- Node.js 20 or higher
- XanoScript VS Code extension installed (
xano.xanoscript) and opened at least once so the bundled language server is available locally
Install from npm
# Global install
npm install -g xanoscript-lint
# One-off run without installing
npx xanoscript-lint --helpDevelop Locally
# Clone the repository
git clone https://github.com/welldundun/xano-lsp-cli.git
cd xano-lsp-cli
# Install dependencies
npm install
# Link globally (optional)
npm linkUsage
Basic Usage
# Validate all .xs files in current directory
xs-lintValidate Specific Files
# Single file
xs-lint src/api/users.xs
# Multiple files
xs-lint src/api/users.xs src/api/posts.xs
# Pattern matching
xs-lint "src/api/**/*.xs"Output Formats
# Human-readable output (default)
xs-lint
# JSON output (for parsing/integration)
xs-lint --json
# Quiet mode (suppress progress messages)
xs-lint --quietPass File Lists via stdin (Automation-Friendly)
# Pipe newline-separated file paths for a stable command signature
printf "%s\n" src/api/users.xs src/api/posts.xs | xs-lint --json --stdinThis is ideal for Claude Skills or CI pipelines where you want to approve a single command and reuse it with different file sets.
CI Pipeline Example
changed_files="$(git diff --name-only origin/main...HEAD | rg '\\.xs$')" || true
if [ -n "$changed_files" ]; then
printf "%s\n" "$changed_files" | xs-lint --json --stdin
fiCustom Server Path
# Specify custom LSP server location
xs-lint --server /path/to/language-server/server.jsOutput Examples
Human-Readable Output
src/api/users.xs:
❌ Line 12:5 - Unexpected token 'function'
Code: unexpected-token
⚠️ Line 24:10 - Unused variable 'userId'
src/functions/helpers.xs:
❌ Line 8:15 - Invalid function syntax
────────────────────────────────────────────────────────────
📊 Summary:
Files checked: 15
Files with issues: 2
❌ Errors: 2
⚠️ Warnings: 1JSON Output
{
"summary": {
"totalFiles": 15,
"filesWithIssues": 2,
"totalErrors": 2,
"totalWarnings": 1,
"totalInfo": 0,
"hasErrors": true
},
"results": [
{
"file": "src/api/users.xs",
"diagnostics": [
{
"line": 12,
"column": 5,
"severity": "error",
"message": "Unexpected token 'function'",
"code": "unexpected-token"
}
],
"errorCount": 1,
"warningCount": 0
}
]
}Claude Code Integration
This CLI includes a built-in Claude Code slash command for AI-assisted debugging and error fixing.
Setup
The .claude/commands/xs-lint.md file is already included in the repository. Claude Code will automatically detect it when working in this directory or any XanoScript project.
Usage with Claude Code
/xs-lintThis will:
- Run diagnostics on all
.xsfiles - Analyze the errors
- Automatically fix issues where possible
- Re-validate to confirm fixes
- Provide a summary of changes
You can also specify files:
/xs-lint src/api/users.xsAfter installing the CLI inside a project workspace, run:
xs-setup --symlinkThis links the .claude skill and command so future CLI updates propagate automatically to Claude Code and other compatible agents.
Exit Codes
0- Success (no errors found)1- Errors found or validation failed
Perfect for CI/CD:
xs-lint || exit 1How It Works
┌──────────────────┐
│ xs-lint CLI │
│ (This Tool) │
└────────┬─────────┘
│ JSON-RPC over stdio
│ (LSP Protocol)
┌────────▼─────────┐
│ XanoScript LSP │
│ Server │ ← From VS Code Extension
│ (server.js) │
└──────────────────┘The CLI:
- Spawns the XanoScript LSP server from your VS Code extension
- Sends standard LSP messages (
initialize,textDocument/didOpen,textDocument/didChange) - Receives diagnostics via
textDocument/publishDiagnostics - Formats and displays the results
Architecture
- bin/xs-lint.js - Main CLI entry point
- lib/lsp-client.js - LSP client wrapper
- lib/validator.js - File validation logic
- lib/formatters.js - Output formatting
- .claude/commands/xs-lint.md - Claude Code integration
Troubleshooting
"XanoScript extension not found"
Make sure you have the XanoScript VS Code extension installed:
code --install-extension xano.xanoscriptOr specify the server path manually:
xs-lint --server /path/to/server.js"No .xs files found"
The CLI searches for files matching **/*.xs in the current directory. Make sure you're in the right directory or specify files explicitly:
xs-lint path/to/your/files/**/*.xsLSP Server Errors
If you see LSP-related errors, try:
- Updating the XanoScript VS Code extension
- Restarting VS Code
- Checking the server.js file exists at the expected location
Development
# Install dependencies
npm install
# Run locally
node bin/xs-lint.js
# Test with specific files
node bin/xs-lint.js test/**/*.xsContributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
MIT
Related Projects
Support
- GitHub Issues: Report a bug or request a feature
- Xano Community: community.xano.com
