> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/format.md).

# format

This command formats new or modified files to align with the Cortex standard. This is useful when developing a new integration, script, playbook, incident field, incident type, indicator field, indicator type, layout, or dashboard. When formatting is complete, the validate command runs and notifies you of any issues the formatter could not fix.

<details>

<summary>Arguments</summary>

| `-i PATH_TO_FILE or PATH_TO_DIRECTORY, --input PATH_TO_FILE or PATH_TO_DIRECTORY` | The path of the file to be formatted. If no input is specified, the formatting will be executed on all new/changed files. |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `-o OUTPUT_PATH, --output OUTPUT_PATH`                                            | Specifies where the formatted file should be saved to. If not used, the default is to overwrite the original file.        |
| `-fv FROM_VERSION_KEY, --from-version FROM_VERSION_KEY`                           | Specifies the minimum version that this content item or content pack is compatible with.                                  |
| `-nv, --no-validate`                                                              | No file validation is needed.                                                                                             |
| `-ud, --update-docker`                                                            | Updates the Docker image of the integration/script to the newest available tag.                                           |
| `-ng, --no-graph`                                                                 | Skips formatting using graphs.                                                                                            |
| `-y/-n, --assume-yes/--assume-no`                                                 | Assumes automatic `yes/no` as an answer to all prompts and runs non-interactively.                                        |
| `-d, --deprecate`                                                                 | Deprecates the integration/script/playbook.                                                                               |
| `-g, --use-git`                                                                   | Uses Git to automatically recognize which files changed and runs `format` on them.                                        |
| `--prev-ver`                                                                      | The previous branch or SHA1 commit to run checks against.                                                                 |
| `-iu, --include-untracked`                                                        | Whether to include untracked files in the formatting.                                                                     |
| `-at, --add-tests`                                                                | Whether to answer manually to add a test configuration prompt when running interactively.                                 |
| `-gr/-ngr, --graph/--no-graph`                                                    | Whether to use the content graph.                                                                                         |

</details>

<details>

<summary>Examples</summary>

* `demisto-sdk format`

  Checks your branch changes and runs only on them.
* `demisto-sdk format -i Integrations/Pwned-V2/Pwned-V2.yml`

  Goes through the integration file, formats it, and overrides the original file with the necessary changes.
* `demisto-sdk format -i Integrations/Pwned-V2/Pwned-V2.yml -o Integrations/Pwned-V2/formatted-Pwned-V2.yml`

  Goes through the integration file, formats it, and saves it to a new file `Integrations/Pwned-V2/formatted-Pwned-V2.yml` with the necessary changes, while keeping the origin file as it was.
* `demisto-sdk format -i Packs/CortexXDR --from-version 10.10.10`

  Formats all JSON/YAML files under the Pack CortexXDR. This also sets the `fromVersion` key in all files to `10.10.10`.
* `demisto-sdk format -i /Users/user/Downloads/Kenna_-_Search_and_Handle_Asset_Vulnerabilities.yml`

  Formats the given YAML file, but validation is not run as this file is not part of the content repository.
* `demisto-sdk format -i /Users/user/Downloads/Kenna_-_Search_and_Handle_Asset_Vulnerabilities.yml -o Integrations/Kenna_-_Search_and_Handle_Asset_Vulnerabilities.yml`

  Formats the given YAML file and saves it in the content repository under the specified file path. Also validation runs as the output file is in the content repository.

</details>

## Set the fromVersion key in different files

### **Run without the fromVersion flag**

#### If the source file name already exists in the content repository

* If the `fromVersion` key exists already in the current file, the `fromVersion` key will not change.
* If the `fromVersion` key does not exist in the current file:
  * If the `fromVersion` key exists in an old file in the content repository, set the `fromVersion` key as in the old file.
  * If the `fromVersion` key does not exist in an old file in the content repository, the system sets the `fromVersion` key to default `1.0.0`.

#### If the source file name does not exist in content repository

* If the `fromVersion` key exists already in the current file, the `fromVersion` key will not change.
* If the `fromVersion` key does not exist in the current file, the system sets the `fromVersion` key to `5.0.0`.

### **Run with the fromVersion flag**

* If the `fromVersion` key exists already in the current file, the system sets the `fromVersion` key to the required version.
* If the `fromVersion` key does not exist in the current file, add the `fromVersion` key and set it to the required version.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/format.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
