Skip to content

Instantly share code, notes, and snippets.

@bobbravo2
Last active August 8, 2025 17:34
Show Gist options
  • Save bobbravo2/c79fa891f4f2ae03bd95083421c02736 to your computer and use it in GitHub Desktop.
Save bobbravo2/c79fa891f4f2ae03bd95083421c02736 to your computer and use it in GitHub Desktop.

Bug Report: read_file tool strips frontmatter from .mdc files

Version: 1.0.0 (Universal)
VSCode Version: 1.96.2
Commit: 53b99ce608cba35127ae3a050c1738a959750860
Date: 2025-06-04T19:21:39.410Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin x64 24.5.0

The rest is LLM output from claude-4-sonnet-max

Bug Description

The read_file tool systematically strips Jekyll-style YAML frontmatter from .mdc (Markdown Cursor Rules) files, creating a fundamental disconnect between filesystem reality and tool accessibility.

Evidence

File System Reality (via terminal cat):

---
description: Defines the canonical specification for .mdc file frontmatter...
globs: ["*.mdc"]
alwaysApply: false
---
# MDC File Frontmatter Specification

Tool Return Value (via read_file):

# MDC File Frontmatter Specification
(frontmatter completely missing)

Binary Confirmation (via hexdump):

00000000  2d 2d 2d 0a 64 65 73 63  72 69 70 74 69 6f 6e 3a  |---.description:|

File definitively starts with ---\n but tool strips everything before first markdown header.

Steps to Reproduce

  1. Create an .mdc file with frontmatter:
---
description: Test rule
globs: ["*.test"]
alwaysApply: false
---
# Test Rule Header
  1. Use AI agent read_file tool to access the file
  2. Compare with terminal cat command output

Expected vs Actual Behavior

Expected: read_file should return complete file content including frontmatter Actual: read_file returns only content after frontmatter closing delimiter

Impact on Development

  • Test Failures: Frontmatter validation tests fail because tools can't access the frontmatter they're meant to validate
  • AI Agent Limitations: Agents cannot programmatically read or edit frontmatter using standard file tools
  • Workflow Disruption: Forces manual verification and reliance on terminal commands for .mdc operations
  • Rule System Broken: Cursor Rules depend on frontmatter, but tools can't inspect it

Current Workarounds

We've had to implement these workarounds:

  • Use run_terminal_cmd with cat for frontmatter inspection
  • Use grep and sed for frontmatter editing
  • Manual verification of all .mdc operations

Request

This bug breaks the fundamental premise of programmatic .mdc file handling. Could you investigate whether this is:

  1. An intentional design decision (and if so, provide alternative frontmatter access methods)
  2. An unintended side effect of Markdown processing
  3. A configuration issue we can resolve

The bug affects our entire .mdc validation framework and forces us to bypass the standard tool ecosystem for these critical configuration files.

Thanks for building such an incredible tool! Even with this bug, the experience has been transformative.

Best regards, [User]

P.S. - Full documentation of our investigation and workarounds is available in our project at .cursor/rules/00-project-meta/mdc-file-frontmatter-specification.mdc under the "🚨 CRITICAL TOOL BUG" section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment