> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meetsilicon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lint your code

> Validate your Silicon Code files against JSON schemas before deploying to catch errors early

The `silicon lint` command validates your Silicon Code files (models, charts, dashboards) against JSON schemas. This helps you catch configuration errors before deploying changes.

## Why use linting?

Linting is especially valuable when:

* **Developing with AI tools** - AI copilots like Cursor, Claude Code, or Kilo Code can generate Silicon YAML files, but may produce invalid configurations. Running `silicon lint` after each change validates the output.
* **Working with dashboards as code** - When editing chart or dashboard YAML files manually, linting catches typos and structural errors.
* **CI/CD pipelines** - Add linting to your deployment workflow to prevent invalid configurations from reaching production.

## Basic usage

Validate all Silicon Code files in the current directory:

```bash theme={null}
silicon lint
```

Validate a specific file:

```bash theme={null}
silicon lint --path ./silicon/charts/revenue-by-month.yml
```

Validate a specific directory:

```bash theme={null}
silicon lint --path ./silicon
```

## Output formats

### CLI output (default)

The default output shows errors in a human-readable format with file paths and line numbers:

```bash theme={null}
silicon lint
```

Example output:

```
✗ ./silicon/charts/my-chart.yml
  Line 15: metricQuery.dimensions must be array

Found 1 error in 1 file
```

## Errors vs. warnings

`silicon lint` reports two severities:

* **Errors** (red `✗`) -- schema validation failures. These cause the command to exit with a non-zero status, so they fail CI.
* **Warnings** (yellow `⚠`) -- non-fatal issues that don't block deployment but signal a configuration that's likely to behave unexpectedly. Warnings do **not** affect the exit code.

### Verbose output

Use `--verbose` to see all validated files, including those that passed:

```bash theme={null}
silicon lint --verbose
```

### SARIF JSON output

For CI/CD integration, use SARIF (Static Analysis Results Interchange Format) output:

```bash theme={null}
silicon lint --format json
```

This outputs results in [SARIF format](https://sarifweb.azurewebsites.net/), which is supported by GitHub Actions, VS Code, and other tools.

## What gets validated

The lint command validates three types of files against their JSON schemas:

| File type | Identified by | Schema |
| - | - | - |
| Models | `type: model` in YAML | [model-as-code-1.0.json](https://github.com/meetsilicon/silicon/blob/main/packages/common/src/schemas/json/model-as-code-1.0.json) |
| Charts | `metricQuery` property | [chart-as-code-1.0.json](https://github.com/meetsilicon/silicon/blob/main/packages/common/src/schemas/json/chart-as-code-1.0.json) |
| Dashboards | `tiles` property | [dashboard-as-code-1.0.json](https://github.com/meetsilicon/silicon/blob/main/packages/common/src/schemas/json/dashboard-as-code-1.0.json) |

The command automatically detects the file type based on its content and applies the appropriate schema.

## Using lint with AI coding tools

> [!NOTE]
>
> **Recommended: Install Silicon Skills first.** Before manually configuring your AI tool, run `silicon install-skills` to install the [Silicon Skills](https://docs.meetsilicon.com/workflow/install-agent-skills.md). The skills already know to use `silicon lint` for validation, so you don't need to configure anything manually.

If you're using Silicon Skills, your AI copilot will automatically run `silicon lint` to validate YAML files as part of its workflow. The skills include best practices for schema validation built-in.

### Manual configuration (without skills)

If you're not using Silicon Skills, you can manually configure your AI copilot to use linting:

1. **Prompt the AI to run lint after changes** - Add instructions like "Always run `silicon lint` after making changes to validate the YAML."

2. **Provide schema references** - Give your AI tool the schema URLs so it understands the expected format:
   * Models: `https://raw.githubusercontent.com/silicon/silicon/main/packages/common/src/schemas/json/model-as-code-1.0.json`
   * Charts: `https://raw.githubusercontent.com/silicon/silicon/main/packages/common/src/schemas/json/chart-as-code-1.0.json`
   * Dashboards: `https://raw.githubusercontent.com/silicon/silicon/main/packages/common/src/schemas/json/dashboard-as-code-1.0.json`

3. **Iterate on errors** - When lint reports errors, have the AI fix them before proceeding.

> [!TIP]
>
> AI tools can run `silicon lint` to validate their own output. This creates a feedback loop that catches errors automatically.

## CI/CD integration

Add linting to your CI/CD pipeline to prevent invalid configurations from being deployed.

### GitHub Actions example

```yaml theme={null}
name: Validate Silicon Code

on:
  pull_request:
    paths:
      - 'silicon/**'

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install Silicon CLI
        run: brew tap silicon/silicon && brew trust silicon/silicon && brew install silicon

      - name: Lint Silicon Code files
        run: silicon lint --path ./silicon
```

### Using SARIF with GitHub Code Scanning

To integrate lint results with GitHub's code scanning:

```yaml theme={null}
- name: Lint with SARIF output
  run: silicon lint --format json > lint-results.sarif

- name: Upload SARIF results
  uses: github/codeql-action/upload-sarif@v2
  with:
    sarif_file: lint-results.sarif
```

## Common errors and fixes

### Missing required properties

```
metricQuery.exploreName is required
```

**Fix:** Add the missing property to your YAML file.

### Invalid property type

```
metricQuery.dimensions must be array
```

**Fix:** Ensure the property value matches the expected type.

### Unknown properties

```
should NOT have additional property 'unknownField'
```

**Fix:** Remove the unrecognized property or check for typos.

## Related

* [Silicon YAML](https://docs.meetsilicon.com/semantic-layer/yaml.md) - Define your semantic layer in YAML without dbt
* [Dashboards as code](https://docs.meetsilicon.com/workflow/content-as-code.md) - Manage charts and dashboards as YAML files
* [Silicon CLI reference](https://docs.meetsilicon.com/workflow/cli/reference.md#silicon-lint) - Full command reference


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.