fix-markdown-fences

Repair malformed Markdown code fence closings across repository directories or files using Python's regex and pathlib libraries.

Updated Jan 19, 2026
One-click install
npx skills add https://github.com/loriensleafs/brain --skill fix-markdown-fences-loriensleafs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fix-markdown-fences
Source: https://github.com/loriensleafs/brain/tree/main/apps/claude-plugin/skills/fix-markdown-fences
Command: npx skills add https://github.com/loriensleafs/brain --skill fix-markdown-fences-loriensleafs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automatically fixes malformed Markdown code fence closings, preventing rendering issues caused by closing fences that carry a language identifier or by unclosed blocks.

Core Features & Use Cases

  • Detect malformed closing fences that include a language specifier and insert a proper plain closing fence.
  • Fix Markdown files across a directory or repository, preserving indentation and multiple code blocks.
  • CLI and programmatic usage to integrate into CI pipelines or local workflows.

Quick Start

Run the fix_fences.py script against your Markdown repository:

  • python fix_fences.py docs
  • python -c "from fix_fences import fix_markdown_files; from pathlib import Path; fix_markdown_files(Path('docs'))"

Frequently Asked Questions about fix-markdown-fences

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix broken Markdown code fences in my repository?

Fix malformed Markdown code fences by running a Python script that detects opening fences with language identifiers, locates malformed closings, and inserts proper plain closing fences across entire directories or individual files.

Why do my Markdown code blocks render incorrectly in READMEs?

Markdown code blocks render incorrectly when closing fences carry a language identifier or blocks remain unclosed. A fence repair tool detects these malformed closings and appends proper plain closing fences to ensure correct rendering.

Can I automate Markdown code fence repair in a CI pipeline?

Automate Markdown code fence repair in a CI pipeline using the CLI or programmatic Python interface. Run the fix script against your docs directory to repair closing fences and ensure code blocks render correctly in generated content.

Does this Markdown fence fixer work across an entire directory of files?

This Markdown fence fixer works across an entire directory of files. It uses Python's pathlib to traverse directories, detecting malformed closing fences with language specifiers and inserting proper closings while preserving indentation and multiple code blocks.

What causes malformed closing fences in Markdown documents?

Malformed closing fences in Markdown documents are caused by closing fences that incorrectly include a language specifier. A Python regex tool detects these malformed closings and inserts a proper plain closing fence to repair the code block structure.