Skip to content

Content Types

xfg supports different content types based on the target file extension.

JSON Files (.json)

Object content outputs as JSON with 2-space indentation:

files:
  .prettierrc.json:
    content:
      semi: false
      singleQuote: true

Output:

{
  "semi": false,
  "singleQuote": true
}

JSON5 Files (.json5)

Object content outputs as plain JSON with 2-space indentation, the same as .json. header lines are written at the top as // comments (see the note under YAML Comments):

files:
  config.json5:
    header: "Do not edit manually"
    content:
      apiUrl: "https://api.example.com"
      timeout: 5000

Output:

// Do not edit manually
{
  "apiUrl": "https://api.example.com",
  "timeout": 5000
}

YAML Files (.yaml, .yml)

Object content outputs as YAML:

files:
  config.yaml:
    content:
      database:
        host: localhost
        port: 5432

Output:

database:
  host: "localhost"
  port: 5432

Strings are double-quoted. Multi-line strings in map values use the | block style; multi-line strings inside arrays stay double-quoted with \n.

YAML Comments

Add schema directives and header comments to YAML files:

files:
  trivy.yaml:
    schemaUrl: https://trivy.dev/latest/docs/references/configuration/config-file/
    header: "Trivy security scanner configuration"
    content:
      exit-code: 1

Output:

# yaml-language-server: $schema=https://trivy.dev/latest/docs/references/configuration/config-file/
# Trivy security scanner configuration

exit-code: 1

A blank line separates the comments from the content. Multi-line headers are also supported:

files:
  config.yaml:
    header:
      - "Auto-generated configuration"
      - "Do not edit manually"
    content:
      version: 1

Note

header applies to YAML files (# lines) and .json5 files (// lines). schemaUrl applies to YAML files only. Both are ignored for .json files, and schemaUrl is ignored for .json5 files.

Text Files

Files with extensions other than .json, .json5, .yaml, or .yml are treated as text files. Use string or string array content:

String Content

files:
  .markdownlintignore:
    content: |-
      # Claude Code generated files
      .claude/

Lines Array Content

files:
  .gitignore:
    content:
      - "node_modules/"
      - "dist/"
      - "coverage/"

Lines are joined with newlines in the output.

Empty Files

Omit content to create an empty file:

files:
  .prettierignore:
    createOnly: true
    # No content = empty file

Validation Rules

  • .json, .json5, .yaml, .yml files must have object content
  • Other file extensions must have string or string array content
  • Mixing content types (e.g., object content in a .txt file) causes a validation error