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

# Insights

In large, evolving codebases, migrations, API transitions, and security anti-patterns often go unnoticed.

Codemod Insights helps you turn repository data into dashboards that show migration progress, API adoption, dependency exposure, and other codebase signals over time.

## How insights work

When you run migrations across many repositories and teams, you need visibility into what changed, what is left, and who owns the remaining work. Insights gives you that visibility through a few reusable building blocks:

* **[Dashboards](#dashboards)** group related widgets around a migration, initiative, or team.
* **[Widgets](#widgets)** show query results as timeseries charts, single numbers, tables, or notes.
* **[Queries](#queries)** pull data from repositories using JSSG codemods, ast-grep YAML rules, Smart natural-language checks, or indexed dependency data.
* **[Template variables](#template-variables)** let you reuse the same dashboard with different repositories, rules, JSSG sources, Smart prompts, or string inputs.

## Dashboards

Dashboards are the top-level container for your insights. Use them to organize widgets by initiative, for example an `i18n migration` dashboard that tracks old API usage, new API adoption, and files remaining across affected repositories.

To create a new dashboard, go to `Insights → Create Dashboard`.

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/create-dashboard.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=daa0a49f9bb3f581ceac774a9b763d3c" alt="Creating a new dashboard" width="3348" height="2120" data-path="images/insights/create-dashboard.png" />
</Frame>

<Tip>
  After a completed [Grep](/enterprise/grep) search, you can create an Insights dashboard from the same query and repository selection. For an AI-native experience while viewing a dashboard, try [Codemod Wish](/enterprise/codemod-wish).
</Tip>

## Widgets

Widgets are the building blocks of a dashboard. Insights supports four widget types:

* **Timeseries chart** - track how a metric changes over time, such as deprecated API calls trending down week over week.
* **Single number** - show a point-in-time value, such as total files still using an old pattern.
* **Table view** - show breakdowns with sorting and row limits, such as remaining work by repository or codeowner.
* **Notes** - add Markdown context, caveats, interpretation, or next actions.

Timeseries chart, single number, and table view widgets are query-backed. They run one or more queries against your repositories and render the results in the selected format. Notes widgets do not run queries.

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/create-widget.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=7d4a53d189550428e4525ccc09c15f32" alt="Creating a new widget" width="2921" height="1084" data-path="images/insights/create-widget.png" />
</Frame>

Each query-backed widget can contain up to 10 queries. Use the query source selector to choose the data source for each query:

* **[JSSG Codemod](/enterprise/insights/jssg-queries)** - runs inline JSSG source, a JSSG codemod package, or a JSSG source template variable.
* **[ast-grep (YAML)](/enterprise/insights/ast-grep-queries)** - runs an ast-grep YAML rule against selected repositories.
* **[Smart](/enterprise/insights/smart-queries)** - describes a file characteristic in natural language and returns a file count.
* **[Dependencies](/enterprise/insights/dependency-queries)** - queries indexed dependency data from selected repositories.

You can select the query source from the dropdown at the start of each query.

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/setting-up-widget.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=8a8051dc21758bdcdfa2302f98eb8380" alt="Setting up a widget" width="1271" height="165" data-path="images/insights/setting-up-widget.png" />
</Frame>

### Formulas

You can combine multiple query results with a formula. Queries are assigned alphabetical variable names (`a`, `b`, `c`, ...) that you can reference in the formula expression.

You can also give the formula result a name using the formula alias field (e.g. `Formula Result`).

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/query-formula.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=e424ba32a513a7cf88b5ea9eb7b10032" alt="Writing formulas" width="1272" height="672" data-path="images/insights/query-formula.png" />
</Frame>

### Visualization settings

Each query-backed widget has visualization options in the **Visualization** tab:

* **Timeseries chart** - choose `Line`, `Bar`, or `Area`, set a Y-axis label, and choose whether to stack series or show dots.
* **Single number** - set a prefix, suffix, and number format.
* **Table view** - configure sorting, row limits, and number formatting.

### Time range

Timeseries widgets include a time range selector that controls the analysis window. You can inherit the dashboard default or set a widget-specific range.

The time range picker supports:

* **Quick ranges** - last 7, 14, 30, 60, or 90 days, and last 4, 8, or 12 weeks.
* **Absolute ranges** - a start and end date, entered manually or selected from the calendar.
* **Now expressions** - values such as `now-30d`, `now-4w`, and `now`.

## Queries

Insights supports four query sources. Each source has its own configuration options and best-fit use cases:

<CardGroup cols={2}>
  <Card title="JSSG (JS ast-grep) queries" icon="code" href="/enterprise/insights/jssg-queries">
    Programmatic analysis, package-backed metrics, and semantic dimensions.
  </Card>

  <Card title="ast-grep YAML queries" icon="file-code" href="/enterprise/insights/ast-grep-queries">
    Syntax-level pattern counts with ast-grep YAML rules.
  </Card>

  <Card title="Package dependency queries" icon="cube" href="/enterprise/insights/dependency-queries">
    Track package adoption, exposure, and dependency drift.
  </Card>

  <Card title="Smart (Jev-powered) queries" icon="sparkles" href="/enterprise/insights/smart-queries">
    Natural-language file-count signals before you have an exact rule.
  </Card>
</CardGroup>

## Template variables

Template variables let you parameterize a dashboard so the same widgets can be reused with different inputs. For example, you can define a repository variable and use it across all widgets, then switch the selected repositories from one place.

To add a template variable, click **Add variable** at the top of your dashboard.

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/create-template-variable.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=091ed9bd0cf90da2d63ebfb5bd26a52e" alt="Adding a template variable" width="579" height="375" data-path="images/insights/create-template-variable.png" />
</Frame>

### Variable types

| Type            | Description                                                                                                                                        |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Repository**  | Select one or more repositories. Repository selectors support up to 10 repositories by default.                                                    |
| **Rule**        | Define an ast-grep YAML rule that can be reused across multiple widgets.                                                                           |
| **JSSG Source** | Define JSSG source that can be reused across multiple widgets.                                                                                     |
| **String**      | Define a text value, optionally with a fixed set of dropdown options. Use string variables for dimension filters, group-by keys, or Smart prompts. |

### Use template variables

Once created, template variables appear as selectable options in query configuration fields. When configuring a query's repository, rule, or JSSG source, you can choose between specifying a value directly or referencing a template variable.

<Frame>
  <img src="https://mintcdn.com/codemod/BAL-G3wPeCjOBtkl/images/insights/using-template-variable.png?fit=max&auto=format&n=BAL-G3wPeCjOBtkl&q=85&s=22f32e7f354eaa645de221a03d6d875d" alt="Referencing template variables" width="571" height="225" data-path="images/insights/using-template-variable.png" />
</Frame>

String variables can be referenced in group-by and dimension filter fields with the `$variableName` syntax. For Smart queries, bind a string variable as the prompt in the editor, or set the prompt to `$variableName` so the same dashboard can switch characteristics without editing every widget.

Variables can be edited from the dashboard view. Widgets that reference a variable refresh with the updated value.

<Tip>
  Template variables are especially useful for dashboards you reuse across repositories, teams, or migration phases.
</Tip>

## Dashboard templates

When you publish a package with JSSG steps to the [Codemod Registry](/enterprise/registry), Codemod attaches a default Insights dashboard template. People who start an Insights dashboard from your package get that template.

You can replace the default with a dashboard you built. If the package is published by an organization, any organization member with developer or admin privileges can update the template.

### Update a package template

<Steps>
  <Step title="Build a package-backed dashboard">
    Create or open an Insights dashboard. Add query-backed widgets that use only your published package. For a bundle, widgets can also be powered by the bundle's child packages. You can optionally include Notes widgets.
  </Step>

  <Step title="Save it as the package template">
    When the dashboard looks right, click the three-dot menu next to the dashboard name and select **Update package template**.
  </Step>
</Steps>
