# prefix-by

## Interface

```typescript
interface parser {
  name: 'prefix-by';
  options: ({
    all: string
  } | 
  {
    group?: string;
    collection?: string;
    token?: string;
  }) & { applyTo?: SDTFQuery }
}
```

## Options

<table><thead><tr><th width="170">Parameter</th><th width="127.33333333333331">Required</th><th width="330">Type</th><th width="136">Default</th><th width="253">Description</th></tr></thead><tbody><tr><td><code>all</code></td><td><code>false</code></td><td><code>string</code></td><td></td><td>Select all collections, groups and tokens in your SDTF token graph.</td></tr><tr><td><code>group</code></td><td><code>false</code></td><td><code>string</code></td><td></td><td>Select all groups in your SDTF token graph.</td></tr><tr><td><code>collection</code></td><td><code>false</code></td><td><code>string</code></td><td></td><td>Select all collections in your SDTF token graph.</td></tr><tr><td><code>token</code></td><td><code>false</code></td><td><code>string</code></td><td></td><td>Select all tokens in your SDTF token graph.</td></tr><tr><td><code>applyTo</code></td><td><code>false</code></td><td><pre class="language-typescript"><code class="lang-typescript">| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQuery
</code></pre></td><td></td><td>The selection where to apply the transformation.<br><br><code>collection</code>, <code>group</code>, <code>token</code> take a Regex string or <code>true</code> to select anything of the kind.<br><br>An <a href="/pages/o67KwpWZQBri4JwW36gc#introduction"><code>SDTFQuery</code></a> can be used for advance use cases.</td></tr></tbody></table>

## Basic usage: Prefix color tokens

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "spacing": {
    "1": {
      "$type": "dimension",
      "$value": {
        "default": {
          "value": 4,
          "unit": "px"
        }
      }
    }
  },
  "colors": {
    "black": {
      "$type": "color",
      "$value": {
        "default": {
          "model": "hex",
          "hex": "#000000",
          "alpha": 1
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json5
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "Prefix color tokens",
      "parsers": [
        {
          "name": "prefix-by",
          "options": {
            "token": "ds-",
            "applyTo": {
              "where": {
                "token": ".*",
                "withTypes": {
                  "include": [
                    "color"
                  ]
                },
                "select": {
                  "parents": true
                }
              }
            }
          }
        },
        {
          "name": "to-sdtf",
          "output": {
            "type": "file",
            "filePath": "tokens.json"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
{% code title="tokens.json" lineNumbers="true" %}

```css
{
  "colors": {
    "ds-black": {
      "$type": "color",
      "$value": {
        "default": {
          "model": "hex",
          "hex": "#000000",
          "alpha": 1
        }
      }
    }
  },
  "spacing": {
    "1": {
      "$type": "dimension",
      "$value": {
        "default": {
          "value": 4,
          "unit": "px"
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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.specifyapp.com/reference/parsers/select-modes-1-1.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.
