review workflow broke when agent ran yamllint on the config: wrong indentation error
Fixes yamllint failing a workflow or config file with wrong-indentation errors. Use it when a YAML file that parses fine gets flagged by yamllint during review or CI, usually after an agent edited it. Key trigger: yamllint reports wrong indentation at a specific line.
TL;DR
Match the indentation yamllint expects, which is almost always 2 spaces with no tabs. Run yamllint, go to the first flagged line, and fix the indent of that block. Re-run until it is clean. If the whole file uses a consistent style that yamllint dislikes, relax the rule in config instead of reformatting everything.
Verbatim error
review workflow broke when agent ran yamllint on the config: wrong indentation errorSteps
- Run yamllint on the file:
yamllint .github/workflows/review.yml.
Expected: output like 14:5: error: wrong indentation: expected 4 but found 6 (indentation). Only fix the FIRST error first; later ones are often knock-on effects.
- Open the flagged line and count spaces. YAML forbids tabs entirely, and nested levels must be consistent. A common agent mistake is mixing 2-space and 4-space indents in one file, or indenting a list item one space too many:
jobs:
review:
runs-on: ubuntu-latestExpected: every level is a multiple of the file's base indent (usually 2), with spaces only.
- Fix the indentation of the flagged block and every line inside it, keeping sibling keys aligned with each other.
Expected: re-running yamllint no longer flags that line.
- If the file is consistently styled (say 4 spaces) and you do not want to reformat, add a yamllint config (
.yamllint.yml) that matches the project style:
rules:
indentation:
spaces: 4 Expected: yamllint exits 0 on the file.
Use this when
- yamllint reports wrong indentation on a workflow or config file.
- An agent edited YAML and the review gate now fails.
- You need to decide between reformatting the file and adjusting yamllint config.
Not for this skill when
- YAML fails to parse at all (that is a syntax error, usually a stray tab or unquoted colon, not indentation style).
- actionlint rejects the workflow (schema problem, not style problem).
- The file is generated and should be excluded from linting instead (add it to yamllint
ignore).
Variant phrasings
- yamllint wrong indentation error in GitHub workflow
- yamllint indentation check fails after agent edited yaml
- how to fix yamllint indentation errors
Why it happens
YAML is whitespace-significant, and yamllint enforces one consistent indentation width per file. Agents editing YAML tend to copy a block from somewhere with a different indent width and paste it in, which parses as valid YAML (or fails loudly) but violates the style rule. The first flagged line is the real break; everything after it is the parser losing track.
Edge cases
- Tabs: YAML spec forbids them for indentation. If an editor inserted tabs, replace them all with spaces.
- Multi-line strings using the literal or folded block scalar style: content lines inside a block scalar are exempt from the rule, so do not "fix" those.
- Anchors and aliases (
&name,*name) confuse some agents into adding extra indent. Keep the alias at the same level as the key it belongs to. - If only one legacy file breaks the rule, add it to the
ignorelist in.yamllint.ymlinstead of churning the diff.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_ha1KtWnC07jJO8Jdzd3wfA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.