AI systems and workflows
The persistent instruction layer of an AI tool: What do .md files actually do?
Imagine that you have built a custom AI tool. The model is ready, its tools are connected, and the interface works. The model still does not automatically know which record your organization treats as authoritative, the order in which a job should run, or when it must return to the user. .md files keep those instructions, domain knowledge, and working rules in a durable source outside the conversation. Persistence here does not mean that the model remembers on its own; it means that the file is retained and loaded back into context for each relevant task.

The simplest answer first
.md is not an AI-specific file format.
Markdown is plain text. A few simple symbols can express headings, lists, links, tables, and code blocks. It opens in any text editor, remains easy for people to read, and is straightforward for software to process. That combination is exactly why it works well in AI systems: the content stays in natural language while its structure remains visible.
Headings communicate hierarchy, lists communicate sequence, and code blocks preserve examples that should not be rewritten. The model sees more than one uninterrupted paragraph; it receives clearer boundaries between topics and their relationships. The extension itself still carries no intelligence. If the surrounding system never discovers or loads the file, that .md file cannot influence behavior.
Markdown is therefore better understood not as 'a format AI likes,' but as a durable instruction and context source that people can author and the system can load again whenever it is needed.
A prompt is not yet a tool
A chat instruction belongs to a session; a .md file survives across sessions.
For a one-off conversation, you can explain the task in a message. A tool used every day, shared by several people, or allowed to act on other systems needs something more durable. Requiring every user to repeat the same explanation makes behavior dependent on individual memory.
Consider an AI tool that evaluates requests arriving at an IT warehouse. It needs more than 'classify this request.' It must know which inventory record is authoritative, how urgency is determined, when an action may happen automatically, and when responsibility must return to a person. Those are not details the model can infer from general knowledge; they are organization- and process-specific requirements.
.md files move those requirements out of chat history and into a durable, version-controlled instruction source. The file alone is not enough: the tool must discover it, load it for the correct task, and provide its contents to the model as context. The model does not learn the instruction forever; the system presents the same definition again whenever it is needed.
Consistency across shifts
Not diagnosing the same alarm from scratch on every shift.
Consider a production-line diagnostic assistant. It evaluates an operator-reported symptom together with PLC or SCADA alarms, sensor trends, equipment documentation, and maintenance history. Source priority, the order of checks, safety boundaries that must never be crossed, and the point at which responsibility returns to a specialist can live in separate .md files instead of one long prompt.
When a pressure alarm repeats, for example, the system first loads its scope and safety rules, then the line equipment map, the relevant alarm knowledge, and the diagnostic workflow. Current pressure and machine state come from an authorized live system rather than a Markdown file. The assistant ranks evidence-based causes and checks, but never recommends bypassing an interlock, disabling a protective circuit, or performing an unauthorized restart. Sensor data can therefore be interpreted and alarm or fault flow managed with the same safety logic across shifts.
The path of an alarm
A diagnostic chain from signal to safe action.
Reliability comes from combining live data, durable instructions, deterministic safeguards, and human authority at the correct points—not from model interpretation alone.
- 01Field signal
PLC / SCADAProvides the current alarm, sensor reading, and machine state from an authorized live source.
- 02Line context
.mdExplains equipment relationships, alarm meaning, the order of checks, and safety boundaries.
- 03Diagnosis
model + toolsCompares evidence, ranks likely causes, and shows the data supporting each hypothesis.
- 04Safety gate
.md + codeApplies stop, authorization, and escalation rules while preventing protective functions from being bypassed.
- 05Controlled output
diagnostic reportSeparates observation, hypothesis, recommended check, confidence, and the person who must take ownership.
An example file architecture
How can a production-line diagnostic assistant be divided into .md files?
This is not a mandatory standard. It is a practical example of separation of responsibilities: each file answers one question and can be loaded only when needed.
line-diagnostics-assistant/
00_SYSTEM_INDEX.mdFile mapExplains what each file governs, when it should load, and which source takes priority when instructions conflict.01_SCOPE_AND_SAFETY.mdScope and safetyDefines the diagnostic tasks the assistant may perform, prohibited actions, and unconditional stop and escalation boundaries.02_LINE_EQUIPMENT_MAP.mdLine and equipment contextDescribes stations, equipment tags, process relationships, and upstream or downstream links that a fault may affect.03_ALARM_KNOWLEDGE.mdAlarm knowledgeCarries alarm-code meanings, known causes, prerequisites, and initial checks grounded in manufacturer documentation.04_DIAGNOSTIC_WORKFLOW.mdDiagnostic workflowDefines the sequence for verifying symptoms, gathering evidence, comparing related alarms, and prioritizing likely causes.05_SOURCE_ROUTING.mdSource routingDefines which information comes from SCADA, the historian, CMMS, maintenance records, or technical documents and how fresh it must be.06_OUTPUT_AND_ESCALATION.mdOutput and handoffDefines how observations, hypotheses, recommended checks, and confidence are reported and when ownership passes to operations, maintenance, or automation.07_VALIDATION_CASES.mdBehavior testsDefines known faults, missing or conflicting data, and negative cases in which the assistant must stop, together with expected outputs.
File names can vary by project. What matters is that every file has one responsibility, an explicit priority, and a rule that determines when it enters context.
Inside one file
What should a single .md file contain?
Take 04_DIAGNOSTIC_WORKFLOW.md as an example. It should be more than a list of possible faults. A useful workflow file separates task scope, required evidence, diagnostic order, stop boundaries, and validation criteria into a structure that both people and the system can interpret consistently.
04_DIAGNOSTIC_WORKFLOW.md- ---
Metadata
Carries routing information such as the file's role, priority, owner, and the conditions under which it should load.
scope: line_diagnostics · priority: binding · load_when: alarm_or_fault
- #
Purpose and scope
States which decision this file governs and which concerns belong to another source.
Defines evidence-based diagnostic steps; PLC changes, interlock bypasses, and machine restarts are outside scope.
- ##
Required evidence
Names the alarm, timing, equipment state, and sensor data that must be verified before diagnosis begins.
Verify the alarm code, timestamp, machine mode, and related sensor trend; never invent missing input.
- ##
Diagnostic sequence
Defines the order in which evidence is compared and hypotheses are prioritized.
Check common causes and simultaneous alarms first, then rank likely causes with supporting and contradicting evidence.
- ##
Stop and escalate
Makes the boundary visible when safety, authorization, or data quality is insufficient for another recommendation.
If a protective circuit, emergency stop, or unauthorized intervention is involved, stop and hand off to the responsible specialist.
- ##
Output and validation
Separates observations from hypotheses and names the evidence required before the result can be accepted.
Show source and timestamp; do not present a likely cause as a confirmed fault; mark it verified only after the prescribed check.
YAML metadata is not mandatory on every platform. The essential principle is to keep scope, required evidence, diagnostic order, stop boundaries, and acceptance criteria under distinct headings rather than mixing them together.
The context budget
Not every file belongs in every task.
Modularity is useful for more than tidy folders. When a user asks for an email draft, inventory policy is irrelevant; when they request data analysis, corporate writing examples are unnecessary. Irrelevant content consumes tokens, reduces the visibility of important rules, and distracts the model.
A well-designed tool first sees concise file descriptions or metadata and then loads only the documents related to the task. Task skills, retrieval, and RAG systems follow the same principle: all knowledge does not stay in context all the time; the right knowledge is retrieved when it is needed.
The name and contents of a file therefore matter alongside its description and trigger. An excellent .md file that no workflow ever calls is archived knowledge, not working context.
Token efficiency
Using .md does not save tokens by itself.
A model's token count is determined by the text that actually enters context, not by the file extension. If substantially the same instruction is supplied in a chat message, a plain-text file, or a .md file, its token count will also be substantially the same. Headings and list markers make the material easier to navigate, but they do not compress it. Simply moving a long prompt unchanged into a .md file therefore creates no inherent token saving.
A Markdown habit can create efficiency indirectly. Shared rules can remain in a short core file, task knowledge can be split into separate documents, and the system can load only the relevant pieces. That reduces repeated explanations and prevents unnecessary context from being sent with every request. The gain comes from selective context management, not from Markdown syntax.
The reverse is also possible. Token use grows when the system loads the entire .md archive for every task, repeats the same rule across several files, or allows documents to accumulate unnecessary examples. A sound approach uses a concise index, routes files through task triggers, removes duplication, and measures the input tokens actually sent on representative requests. The goal is not to use the fewest tokens at any cost; it is to provide the smallest clear context that still supports the right decision.
Two approaches
The same knowledge, two different architectures.
The design question is not only whether Markdown is used. It is how knowledge is divided and when each part enters context.
One giant prompt
- The role, rules, all domain knowledge, and every example live in one text.
- The entire body enters context for every request.
- A small edit may affect unrelated tasks.
- Contradictions, duplication, and stale information are difficult to find.
Modular .md files
- Shared principles, workflows, knowledge, and examples occupy separate layers.
- Only relevant files load when needed.
- The scope and owner of each change are clearer.
- A behavior change can be reviewed as a small Git diff.
Show, do not only tell
EXAMPLES.md can be more useful than ten pages of rules.
AI models learn strongly from patterns as well as explicit rules. 'Write a concise, technical, non-accusatory explanation' provides direction; a good example simultaneously demonstrates length, tone, level of detail, and paragraph rhythm.
Good-and-bad example pairs are especially valuable for output schemas, error messages, report formats, and tool-routing decisions. They show the model what an acceptable result looks like and what must not pass. This is often more effective than adding more adjectives and abstract instructions.
An example should not become the only correct answer. A small representative set should expose the boundaries of behavior without forcing the model to copy names and sentences mechanically.
The right information in the right layer
.md is not a replacement for everything else.
A custom AI tool works through several layers with different responsibilities. Markdown is an important part of the system, not the whole system.
- 01Model
LLMReasons about context, interprets ambiguity, and produces natural language.
- 02Behavior and domain knowledge
.mdCarries purpose, workflow, rules, terminology, and examples.
- 03Deterministic operation
codeMakes calculations, validation, file conversion, and API operations repeatable.
- 04Configuration
JSON / YAMLStores schemas, parameters, and values that machines must parse exactly.
- 05Current or large-scale data
API / DB / vector searchRetrieves volatile records and high-volume knowledge when needed.
Version control
A change to a .md file is a change to behavior.
When instruction files live in a version-control system such as Git, changes to the tool's behavior become visible. Teams can inspect which rule was added, why an exception changed, and how the previous version worked line by line. The change can be rolled back when necessary.
This moves prompt editing away from private experimentation and closer to a managed engineering activity. A domain expert can review the wording, a developer can assess technical feasibility, and the modified behavior can be tested again with the same example tasks.
History alone does not guarantee quality. It does, however, replace 'the model answered differently again' with a concrete check of whether the behavior definition supplied to the model also changed.
Boundaries
Not everything belongs in a .md file.
Passwords, access keys, and sensitive personal information should not live in readable text files. Constantly changing inventory, prices, and user lists should not be copied into Markdown either; they should come directly from the current system. Markdown may explain how to use a source, but it should not replace a live source.
Deterministic work such as exact calculation, authorization, schema validation, and data transformation should not rely on natural-language instructions. If the same input must always produce the same result, code should enforce that behavior.
Finally, a well-written file does not guarantee correct behavior. The system must actually load it, the rules must remain consistent, and the tool must be tested against positive and negative scenarios. Documentation creates control; it does not replace verification.
A practical starting point
Five clear decisions are enough for a first version.
Before increasing the file count, make the tool's operating logic visible through five questions.
- 01
Which problem does the tool solve, for whom, and which work is explicitly out of scope?
- 02
Which sources are authoritative during the task, and which domain terms need a fixed meaning?
- 03
Which steps, decision points, and completion criteria define the workflow?
- 04
Which operations belong in code or tools, and when must the system ask the user or stop?
- 05
What do a good result, a bad result, and a boundary case look like in concrete examples?
References and further reading
- An explicit, interoperable syntax definition for MarkdownCommonMark Specification
- Layering project-wide AI instructions with AGENTS.mdOpenAI Codex — Custom instructions with AGENTS.md
- Packaging instructions, references, and scripts as reusable skillsOpenAI Codex — Build skills
- The SKILL.md structure, YAML frontmatter, and supporting resourcesAgent Skills — Specification
- Exposing current context and application data to models as resourcesModel Context Protocol — Resources
Working with .md files is not merely saving one long prompt into a document. The real design work is separating the tool's identity, knowledge, workflow, rules, and examples into manageable parts. Building a strong custom AI tool is therefore not only prompt engineering; it is also requirements engineering and system design.
