fix-unclosed-fenced-block-en — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited fix-unclosed-fenced-block-en (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Detect and fix unclosed fenced blocks ( ` ) in Markdown output. Fenced blocks are used for code, terminal output, file trees, config files, examples, and any verbatim content.
When an AI assistant generates Markdown, it sometimes opens a fenced code block with ` (optionally followed by a language hint such as bash or markdown) but then omits the matching closing ` . The symptom is that the next heading or section renders inside the code block instead of as normal Markdown.
Typical broken pattern:
Some prose text.
skills-ref validate ./skills/my-skill
---
## Detection algorithm
Scan the Markdown text **line by line** and maintain a simple toggle:
| State | Trigger | Action |
|-------|---------|--------|
| OUTSIDE | Line matches `` /^```/ `` | Switch to INSIDE, record line number and language hint |
| INSIDE | Line matches `` /^```\s*$/ `` (closing fence) | Switch to OUTSIDE |
| INSIDE | Line matches `^#{1,6} ` (ATX heading) | **Missing close detected** — insert ` ``` ` before the heading |
| INSIDE | End of document reached | **Missing close detected** — append ` ``` ` at end |
> A closing fence must be **exactly** three or more backticks on their own
> line (optional trailing whitespace). A line that starts with ` ``` ` but
> has additional non-whitespace characters is an **opening** fence.
---
## Fix procedure
### Step 1 — Identify all unclosed blocks
Apply the detection algorithm above to the full input text and collect every
location where a closing fence is missing.
### Step 2 — Insert closing fences
For each missing close (in reverse order so line numbers stay valid):
1. Insert a line containing exactly ` ``` ` immediately **before** the
triggering heading (or at the end of the document).
2. Add a blank line after the inserted fence if one is not already present,
to preserve heading spacing.
### Step 3 — Verify the result
Re-run the detection algorithm on the repaired text and confirm that no
unclosed blocks remain.
### Step 4 — Report
Tell the user:
- How many unclosed blocks were found and fixed.
- The approximate location of each fix (heading text or "end of document").
---
## Self-check before output
Before delivering **any** Markdown response, mentally (or literally) run the
detection algorithm on your own output. If an unclosed block is found,
apply the fix before sending.
Checklist:
- [ ] Every ` ``` ` opener has a matching ` ``` ` closer on its own line.
- [ ] No ATX heading (`#` … `######`) appears between an opener and its closer.
- [ ] The document does not end while inside a fenced block.
---
## Examples
### Example 1 — heading triggers missing close
**Input (broken):**
Preserve language hints:
skills-ref validate ./skills/my-skill
## CitationsFixed output:
Preserve language hints:skills-ref validate ./skills/my-skill
## CitationsInput (broken):
Keep inline citation format:
According to the agentskills.io specification, the name field must match the directory name exactly.
**Fixed output:**
Keep inline citation format:
According to the agentskills.io specification, the `name` field must match
the directory name exactly.
---
## Edge cases
| Situation | Handling |
|-----------|----------|
| Nested backtick fences (four backticks) | Track fence depth; a four-backtick opener closes with four backticks |
| Inline backticks (single or double) | Ignored — only triple-backtick fences are relevant |
| Indented code blocks (4 spaces) | Not affected by this skill |
| Fence with language hint | Opening fence; closing fence has no hint |
| Multiple consecutive unclosed blocks | Fix each one individually in document order |
---
## Attribution
fix-unclosed-fenced-block-en — part of the roebi agent-skills library Author : roebi (Robert Halter), Switzerland License: CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ Spec : https://agentskills.io/specification Source : https://github.com/roebi/agent-skills
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.