Skip to content

fix(skills): handle single-line descriptions in SKILL.md frontmatter#28042

Open
saiteja00743 wants to merge 1 commit into
google-gemini:mainfrom
saiteja00743:fix/skill-discovery-single-line-description
Open

fix(skills): handle single-line descriptions in SKILL.md frontmatter#28042
saiteja00743 wants to merge 1 commit into
google-gemini:mainfrom
saiteja00743:fix/skill-discovery-single-line-description

Conversation

@saiteja00743

Copy link
Copy Markdown

Summary

Fix skill discovery silently failing when the description field in SKILL.md frontmatter is written on a single line (i.e., the closing --- marker immediately follows the description with no blank line). Affected skills were completely invisible in /skills list.

Details

The root cause was two-fold:

  1. FRONTMATTER_REGEX did not account for UTF-8 BOMs (\uFEFF) at the start of files, or trailing whitespace on --- delimiter lines, causing the regex to fail to match valid frontmatter blocks.

  2. parseSimpleFrontmatter (the fallback YAML parser) incorrectly split single-line descriptions when subsequent lines contained name: or description:. It also was not case-insensitive and required exact colon formatting.

Changes to skillLoader.ts:

  • Updated FRONTMATTER_REGEX to strip UTF-8 BOMs and tolerate trailing spaces/tabs on --- lines.
  • Refactored parseSimpleFrontmatter to be case-insensitive, support optional spaces before colons, and use a negative lookahead to prevent misidentifying value lines as new keys.
  • Replaced an unsafe as Record<string, unknown> type assertion with a proper isRecord() type guard to satisfy @typescript-eslint/no-unsafe-type-assertion.

Changes to skillLoader.test.ts:

  • Added 7 new regression tests covering: single-line descriptions, UTF-8 BOM presence, trailing spaces after delimiters, case-insensitive keys, optional spaces before colons, robust non-string value casting, and indented description edge cases.

Related Issues

Fixes #25693

How to Validate

  1. Create a skill with a single-line description:
    ---
    name: my-test-skill
    description: A single-line description
    ---
    Skill body here.
  2. Place it in ~/.gemini/skills/my-test-skill/SKILL.md
  3. Run npm run build && npm run start
  4. Inside the CLI, run /skills list
  5. Expected: my-test-skill appears with its description
  6. Before fix: The skill would be missing from the list entirely

Alternatively, run the unit tests:

npm test -w @google/gemini-cli-core -- src/skills/skillLoader.test.ts

All 21 tests should pass.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed) — no docs changes required
  • Added/updated tests (if needed) — 7 regression tests added
  • Noted breaking changes (if any) — no breaking changes
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Prior to this fix, the skill discovery logic failed to correctly parse
SKILL.md frontmatter when the 'description' field was written on a single
line (i.e., no trailing newline before the closing '---' marker). This
caused affected skills to be silently dropped from the skills registry.

Changes:
- Updated FRONTMATTER_REGEX to handle UTF-8 BOMs and trailing whitespace
  on the '---' delimiter lines.
- Refactored parseSimpleFrontmatter to be case-insensitive, support
  optional spaces before colons, and use a negative lookahead to prevent
  incorrectly splitting descriptions when subsequent lines contain
  'name:' or 'description:'.
- Added isRecord() type guard to replace an unsafe 'as' type assertion,
  satisfying @typescript-eslint/no-unsafe-type-assertion.
- Added comprehensive regression tests covering: single-line descriptions,
  UTF-8 BOM presence, trailing spaces after delimiters, case-insensitive
  keys, and indented description edge cases.

Fixes google-gemini#25693
@saiteja00743 saiteja00743 requested a review from a team as a code owner June 19, 2026 16:27
@github-actions github-actions Bot added the size/m A medium sized PR label Jun 19, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 169
  • Additions: +158
  • Deletions: -11
  • Files changed: 2

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug where skills with single-line descriptions in their SKILL.md frontmatter were failing to load. By improving the regex and fallback parsing logic, the system is now more resilient to variations in formatting, encoding, and indentation, ensuring all valid skills are correctly discovered.

Highlights

  • Frontmatter Parsing Robustness: Updated the frontmatter regex to support UTF-8 BOMs and tolerate trailing whitespace on delimiter lines, ensuring valid frontmatter is correctly identified.
  • Fallback Parser Improvements: Refactored the simple frontmatter parser to be case-insensitive, support flexible colon spacing, and prevent incorrect swallowing of subsequent keys during multi-line description parsing.
  • Type Safety: Replaced unsafe type assertions with a robust isRecord type guard and added explicit string casting for frontmatter values.
  • Regression Testing: Added 7 new unit tests covering edge cases like single-line descriptions, BOMs, trailing spaces, and case-insensitive keys.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances frontmatter parsing in skillLoader.ts by supporting UTF-8 BOM, trailing spaces, case-insensitive keys, and non-string YAML values. It also adds a safe isRecord type guard and prevents the fallback parser from swallowing subsequent keys. A comprehensive suite of unit tests has been added to verify these improvements. No review comments were provided, so there is no additional feedback.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Skills discovery fails when 'description' in SKILL.md frontmatter is a single line

1 participant