Skip to content

Conversation

@NTaylorMullen
Copy link
Collaborator

Summary

This PR adds a 'hardening' pass on top of the recently merged fix for issue #16323. It makes the simple frontmatter parser more resilient to variations in user formatting.

Details

  • Regex-based matching: Replaced string prefix checks with regex to allow for leading whitespace and missing spaces after colons (e.g., name:foo).
  • Improved Multi-line Joining: Refined the array-based approach to ensure clean joining of indented lines without accidental leading spaces.
  • Safety Checks: Added a null check for the skill body to prevent crashes if a SKILL.md file contains frontmatter but no subsequent content.
  • Expanded Test Suite: Added 6 new test cases covering edge cases like empty values, indented fields, and missing spaces.

Related Issues

Related to #16323

How to Validate

Run the updated test suite:

npx vitest run packages/core/src/skills/skillLoader.test.ts

Verified that all 13 tests pass, including the 6 new edge case scenarios.

Pre-Merge Checklist

  • Added/updated tests (if needed)
  • Validated on required platforms/methods:
    • MacOS
      • npm run

This commit adds a 'hardening' pass on top of the initial fix for issue #16323:
- Use regex for more flexible name and description field matching
- Support missing space after colons in frontmatter (e.g. 'name:foo')
- Support indented field names in frontmatter
- Add safety check for missing body in SKILL.md
- Add comprehensive test cases for frontmatter edge cases
@NTaylorMullen NTaylorMullen requested a review from a team as a code owner January 15, 2026 02:28
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @NTaylorMullen, 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 significantly improves the robustness and flexibility of the skill frontmatter parsing mechanism. By adopting more adaptive matching techniques and enhancing error handling, the system can now gracefully process a wider range of user formatting styles, preventing issues that might arise from non-standard input.

Highlights

  • Robust Frontmatter Parsing: The skill frontmatter parser has been enhanced to use regular expressions for matching 'name' and 'description' fields, making it more resilient to variations like leading whitespace and missing spaces after colons.
  • Improved Multi-line Description Handling: The logic for parsing multi-line descriptions has been refined to correctly join indented continuation lines without introducing accidental leading spaces.
  • Null Safety for Skill Body: A null check was added for the skill body content, preventing potential crashes if a SKILL.md file contains only frontmatter without any subsequent body text.
  • Expanded Test Coverage: Six new test cases have been introduced to cover various edge cases, including empty name/description values, indented fields, and missing spaces after colons, ensuring the parser's reliability.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Collaborator

@abhipatel12 abhipatel12 left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link

Size Change: +74 B (0%)

Total Size: 23.1 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23 MB +74 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

Copy link
Contributor

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

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 effectively hardens the frontmatter parsing for skills by using regular expressions to handle formatting variations like leading whitespace and missing spaces after colons, and adds a crucial safety check to prevent crashes when a skill file lacks a body. The accompanying tests are comprehensive and cover the new edge cases well. To further improve the parser's resilience, consider making the key matching case-insensitive for name and description fields.

if (line.startsWith('name:')) {
name = line.substring(5).trim();
// Match "name:" at the start of the line (optional whitespace)
const nameMatch = line.match(/^\s*name:\s*(.*)$/);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The regex for matching the name field is case-sensitive. To be more resilient to user formatting variations, as is the goal of this refactor, consider making it case-insensitive. A user might write Name: which would currently fail to be parsed by this fallback parser.

Suggested change
const nameMatch = line.match(/^\s*name:\s*(.*)$/);
const nameMatch = line.match(/^\s*name:\s*(.*)$/i);

if (line.startsWith('description:')) {
const descLines = [line.substring(12).trim()];
// Match "description:" at the start of the line (optional whitespace)
const descMatch = line.match(/^\s*description:\s*(.*)$/);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The regex for matching the description field is case-sensitive. To be more resilient to user formatting variations, consider making it case-insensitive. A user might write Description: which would currently fail to be parsed by this fallback parser.

Suggested change
const descMatch = line.match(/^\s*description:\s*(.*)$/);
const descMatch = line.match(/^\s*description:\s*(.*)$/i);

@NTaylorMullen NTaylorMullen added this pull request to the merge queue Jan 15, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 15, 2026
@NTaylorMullen NTaylorMullen added this pull request to the merge queue Jan 15, 2026
Merged via the queue into main with commit d0bbc7f Jan 15, 2026
25 checks passed
@NTaylorMullen NTaylorMullen deleted the ntm/skill-parser-hardening branch January 15, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants