# Actions

Create dynamic suggestions for your rules with Actions.

{% hint style="info" %}
Heads up!

See [`vale-ls`](/guides/lsp.md) for an easy way to integrate Actions into your favorite text editor.
{% endhint %}

Actions provide a way for users to define dynamic fixes for their custom rules that show up in the CLI and LSP-based integrations.

![Actions](/files/93f6681a0fc12a2033fb6108edda4459745d01c9)

In the Sublime Text example above, the “Quick Fix” menu is powered by the action defined in the rule definition:

{% code title="rule.yml" %}

```yaml
action:
  name: replace
```

{% endcode %}

See the documentation on each `action` type for more information:

| Name                           | Description                                                                                  |
| ------------------------------ | -------------------------------------------------------------------------------------------- |
| [`suggest`](/fixes/suggest.md) | An array of dynamically-computed suggestions.                                                |
| [`replace`](/fixes/replace.md) | An array of static suggestions. Supported by default in `substitution` and `capitalization`. |
| [`remove`](/fixes/remove.md)   | Remove the matched text.                                                                     |
| [`edit`](/fixes/edit.md)       | In-place edits of the matched text.                                                          |

## [CLI](#cli)

Most Vale rules are based on *static* suggestions—for example,

{% code title="rule.yml" %}

```yaml
extends: substitution
message: "Use '%s' instead of '%s'."
level: error
action:
  name: replace
swap:
  Javascript: JavaScript
```

{% endcode %}

Here, the `action` is a to *replace*`Javascript` with `JavaScript`. In such cases, we know what we want to suggest to the user ahead of time and Vale can easily generate the appropriate output message.

However, there are cases in which we *don’t* know the appropriate suggestion ahead of time. For example, consider the following rule:

{% code title="rule.yml" %}

```yaml
extends: existence
message: "'%s' should be '%s'."
level: error
action:
  name: edit
  params:
    - regex
    - '(\w+)_(\w+)'
    - '$1-$2'
tokens:
  - '\w+_\w+'
```

{% endcode %}

This rule is designed to catch instances of `snake_case` and suggest that the user convert to `kebab-case`. In this case, the exact suggestion is dependent on a string transformation that needs to be computed at runtime.

Using the `edit` action allows us to define a rule that can dynamically generate suggestions based on the matched text in CLI output:

![CLI](/files/2a0b35909e2addb889d0091f3a65857126bd38f0)

As you can see, the CLI output is dynamically computing the suggestion based on the matched text.

## [LSP](#lsp)

In both static and dynamic cases, any application that uses the [Vale Language Server](/guides/lsp.md) will be able to provide the user with a list of “Quick Fixes” that can be applied to the document.

[Scopes](/topics/scopes.md) [Filters](/topics/filters.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vale.sh/topics/actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
