Artificial Intelligence

Markdown Files and Context Engineering When Working with AI Agents

In this post we explain what MD files are, how they are used in AI workflows, and why defining them correctly matters when working with agents.

Avi Levi
Avi Levi Updated: March 14, 2026
old book with ai metadata

What Are Markdown Files?

Markdown files are plain text files that use a markup language to format text — which is also where the name comes from. They are designed to be clear and readable for humans while also allowing easy conversion to styled formats such as HTML.

What Characterizes MD Files

  1. Simplicity and readability — these files rely on graphical symbols such as # or * to create document hierarchy and display formatting elements, making the file readable in any application.
  2. Platform independence — Markdown files can be edited in any basic text editor such as Notepad, or in development tools such as VS Code.
  3. Easy conversion to other formats — because they are based on globally agreed-upon conventions, these files are very easy to convert to languages such as HTML for clean, styled rendering in browsers.

What Does an MD File Look Like?

# Personal Blog Project
**created: 14 May 2026**

## The Blog Perpose
The purpose of my blog is to make AI, digital tools, and learning ideas practical, clear, and useful for real people who want to grow, create, and work smarter.

---
## Tasks
- [x] Buy Domain
- [x] Select Hostig Service
- [ ] Write first 5 posts
- [ ] Adding contact info

Examples of common syntax:

  • Headings — marked with # at the start of a line, for example: # Main Heading or ## Subheading.
  • Bold text — displayed with double asterisks before and after the word or phrase, for example: **bold text**.
  • Lists — marked with - or * at the start of a line.
  • Links — formatted using square brackets followed by parentheses: [site] (https://fakeurl.com).
markdown file in vs code
A Markdown file displayed in the VS Code development environment

Why Is This Such a Good Format for AI?

Working with MD files is highly efficient in AI workflows because it is a token-efficient format. Language models do not read words — they break them down into tokens (small units of text). Documents and formats such as HTML, with their abundance of tags, “waste” a large number of tokens. The MD format is a “lean” format that uses single characters (# or *) for formatting, which allows far more information to be packed into the context window.

Another factor that significantly affects an AI’s ability to understand information is hierarchy. MD files provide the AI with a clear, hierarchical structure. Headings help it understand what is a primary topic and what is secondary, lists and tables allow models to scan data and understand the relationships between items, and code blocks allow instructions to be “injected” into models.

Finally, most of these models were trained on data from the internet — such as code repositories on GitHub or technical documentation — content that is largely written in Markdown. This means models find it easier to parse this format and produce it as output.

A Markdown file strikes a balance between plain text that is easy to read and rich structure — without the “noise” of tags and styling. That said, if we want the AI to avoid wasting tokens and to work more efficiently, we need to provide it with context about the document: information that helps the model before it even reads the content. This information is called YAML Frontmatter.


What Is YAML Frontmatter and Why Is It Critical for Working with AI?

Imagine walking into a vast library. The shelves hold thousands of books, but none of them have any information on the cover — no title, no author, no publication year, no genre. In that case, to find out what a book is about, you would have to open it and start reading. That is exactly what our documents look like to an AI: just a plain text file, with no metadata.

In simple terms, YAML Frontmatter is a “block” of information that appears at the very beginning of a file. It is separated from the rest of the text by three dashes (---) and contains metadata about the file in a simple key-value structure (for example: date: 2024-03-14). This is the information that gives the AI context about the document.

Now imagine that every book has a small sticker on the top of its first page listing details such as the title, genre, and publication date. That sticker is essentially the YAML Frontmatter.

But this is not only useful for AI — it also serves content management systems (CMS), document management tools such as Notion or Obsidian, and development and version control tools such as GitHub.

Why Does This Matter When Working with AI?

When we work with models such as Claude Code, build Skills, or design agent-based systems, Frontmatter matters for three reasons:

  1. Providing precise context — when we feed the AI a file with Frontmatter, we do not need to explain “this is an article written by John in 2020.” The AI recognizes the structure immediately and understands the context of the text automatically.
  2. Order within the chaos (knowledge organization) — if we have hundreds of notes in tools such as Obsidian or Notion, Frontmatter allows the AI to filter and locate specific information. For example: “Find me all the meeting protocols tagged as ‘urgent’ from the past month.” The AI searches for the word “urgent” inside the Frontmatter and does not confuse it with regular body text.
  3. Task automation — this allows us to instruct the AI, for example: “Go through all my blog post files; if the Frontmatter shows the status is ‘draft’, add a summary paragraph to each one.” YAML Frontmatter acts here like a “remote control” that tells the AI which files to act on and what to do with them.

What Does YAML Frontmatter Look Like?

The block always appears at the beginning of the file, enclosed between two lines of three dashes (---):

---
title: "A Guide to YAML"
date: 2024-03-14
author: "Jane Smith"
tags: [guide, development]
draft: false
---
The file content begins here...

What the YAML block should include:

  1. It must appear on the very first line of the file.
  2. Data is formatted as key-value pairs, for example: updated: 2024-03-14.
  3. The YAML is separated from the rest of the content by three dashes (---) both before and after it.

How Does All This Relate to Working with AI Agents?

Now that we understand what YAML is, let’s see how it works in practice with AI agents.

When we integrate agents into our workflow — AI agents are artificial intelligence tools that can perform actions autonomously — it is important to define how they should operate: what they need to do, what processes they should manage, what permissions they have, what tools they are connected to, and so on.

This is where Skills come in. We add capabilities to the agent — such as sending emails, updating a calendar, or running code — and define what it needs to do, how to do it, what it is and is not allowed to do, and which tool to use.

Let’s illustrate this with a social media agent. An agent of this type needs a Skill for publishing on social networks, which would consolidate the writing guidelines for each platform. But for the agent to know which Skill to activate, it needs clear information — so it does not waste a large number of tokens reading entire documents before it finds the right Skill.

This is where YAML Frontmatter comes in. When the agent accesses a file, it first reads the YAML to determine whether this document contains the relevant Skill. If not, it moves on until it finds the right one — and in doing so, it does not “waste” tokens from the context window.

The idea is straightforward: the Skill is the Markdown document, and at the top of that document sits a YAML block that gives the agent information about the document so it does not have to read the whole thing.

This applies not only to Skills but also when we want an agent to publish a draft we have written. Imagine you have a document with this YAML:

---
task type: "distribute"
Channel: "LinkedIn"
Tone: "enthusiastic"
---
Content: We have successfully built a new social agent that publishes content online autonomously.

Here is how the agent would work in this case:

  1. The agent scans the YAML and identifies the key “distribute.”
  2. That word triggers the publishing Skill.
  3. It reads channel: "LinkedIn" and knows the distribution channel.
  4. It reads the Tone field and knows how to style the post.
  5. Only then does it read the content.

If the task_type had been “distributed,” the agent would simply have moved on.


Summary

Working with Markdown and YAML files enables precision — the agent does not “guess” what to do with a file. It enables speed and efficiency — instead of reading an entire document, the agent reads four lines and knows whether it is relevant and what needs to be done with it. And it makes automation possible, allowing you to manage hundreds of files whose agents know exactly what to do with them — all thanks to the small “sticker” you placed at the top of each file.

Was this article helpful?

Your answer helps me understand which posts actually create value, beyond page views.