USMAN’S INSIGHTS
AI ARCHITECT
  • Home
  • About
  • Thought Leadership
  • Book
Press / Contact
USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeBook
HomeBookSpecification by Example Eliminating Logic Gaps with Code Blocks
Previous Chapter
Mapping Dependencies with Lists and Sequential Logic
Next Chapter
Enriching Specifications with Multimedia and Emphasis
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

23 sections

Progress0%
1 / 23

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a leading Agentic AI Architect and Software Engineer specializing in the design and deployment of multi-agent autonomous systems. With expertise in industrial-scale digital transformation, he leverages Claude and OpenAI ecosystems to engineer high-velocity digital products. His work is centered on achieving 30x industrial growth through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. Based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Book
  • About
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

module: "MODULE 2" category: "DIGITAL FTES: ENGINEERING" title: "Show AI Exactly What You Mean — Stop Describing, Start Demonstrating" description: "Vague descriptions produce inconsistent results. Code blocks give AI a concrete target — exact output format, command syntax, and implementation examples that eliminate guesswork entirely." cta_hook: "If you can't show it in a code block, your spec isn't precise enough." warning_banner: "Tagging expected output as 'python' instead of 'text' tells AI the output is code to implement — not a format to replicate. One wrong language tag, completely wrong generation." the_3_rules: title: "Fenced Blocks = Exact Targets" description: "Triple backtick code blocks preserve every character exactly as typed. This turns your expected output into an acceptance test — AI builds until its output matches yours." fix: "Fix → Fenced Code Blocks" title: "Language Tags Are Semantic" description: "bash vs python vs text are not style choices — they tell AI what kind of content it's reading. Wrong tag = wrong interpreter = misaligned generation." fix: "Fix → Correct Language Tags" title: "Inline Code = Literal Strings" description: "Backtick-wrapped content tells AI: treat this exactly as written. Without inline code, AI may rephrase 'python tracker.py' as 'run the tracker' — losing the exact command." fix: "Fix → Semantic Anchoring" what_this_fixes: flow: step1: "Vague Description" step2: "Code Block Example" step3: "Spec by Example" result: "100% Fidelity Output" quote: "When AI can see exactly what 'correct' looks like, it stops guessing and starts matching. Code blocks are your acceptance tests written before a line of code exists." short_hook: "Describe less. Demonstrate more."

Specification by Example: Eliminating Logic Gaps with Code Blocks

Vague descriptions like "show a greeting" lead to inconsistent results. This lesson teaches you the power of Specification by Example using Markdown code blocks. You will learn how to provide AI agents with concrete targets—including exact output formats, command-line syntax, and multi-line code patterns—ensuring that your implementation matches your vision with 100% fidelity while eliminating the "guesswork" that causes manual rework.

Lists vs Code Blocks

In the previous lesson, you learned lists for organizing content. Code blocks serve a different purpose — they preserve exact formatting. Here's the key distinction:

Side-by-side comparison showing unordered lists versus fenced code blocks
Side-by-side comparison showing unordered lists versus fenced code blocks

Lists organize ideas into readable bullet points or numbered steps. Code blocks preserve exact formatting — every space, every character appears exactly as you type it. Use lists to describe what the software does; use code blocks to show what it looks like when running.


Concept 1: Fenced Code Blocks (Multiple Lines)

Use fenced code blocks when you need to show multiple lines of code or output.

Basic Syntax

Create a fenced code block with triple backticks (the ` key, usually below Escape):

What you type in your markdown file:

markdown
```text Line 1 of code or output Line 2 of code or output Line 3 of code or output ```

What it renders as:

text
Line 1 of code or output Line 2 of code or output Line 3 of code or output

[!TIP] Pro-Tip: Documenting Code Blocks When writing documentation that shows code block syntax (like this lesson), use quadruple backticks to wrap examples containing triple backticks. This prevents the inner backticks from closing your outer block.

Example: Showing Expected Output

text
Tasks: 1. Buy groceries [Pending] 2. Call dentist [Complete] 3. Submit report [Pending]

Example: Showing Program Code

python
def add(a, b): return a + b result = add(5, 3) print(result) # Should print: 8

Concept 2: Language Tags (For Clarity)

Add a language tag right after the opening backticks to specify what type of code it is.

Common Language Tags

  • python — Python code
  • bash — Terminal commands
  • text — Plain output (no code)
  • typescript — TypeScript code
  • json — Data formats
  • yaml — Configuration files

[!IMPORTANT] Use the Correct Tag AI agents are sensitive to language tags. If you tag Python code as text, the AI may ignore syntax rules. If you tag plain output as python, AI treats it as code to implement. Always use the correct language tag.

Two code blocks comparing syntax highlighting
Two code blocks comparing syntax highlighting

Example: Installation Commands

bash
pip install requests python app.py

Example: Python Code

python
def greet(name): return f"Hello, {name}!" print(greet("Alice"))

Concept 3: Inline Code (Single Backticks)

Use inline code for short code references within regular text — like variable names, commands, or file names.

Syntax

markdown
Install the package with `pip install requests` command. The `app.py` file contains the main function. Set the `DEBUG` variable to `True` for testing.

When to Use Inline Code

  • Command names: python, git, npm
  • Variable names: user_name, total_count
  • File names: README.md, app.py
  • Function names: calculate_total(), get_user()

Fenced vs Inline: Which to Use?

FeatureSyntaxUse Case
Inline Code`code`Variable names, file names, short commands in a sentence
Fenced Block```Multi-line code, program output, or implementation examples

Practice Exercise: Task Tracker App (Part 3 - Code Blocks)

Your Task for Lesson 4

Part 1: Add Expected Output Section

markdown
## Expected Output When the user runs `python tracker.py`, they should see: ```text Task Tracker Menu 1. Add Task 2. View Tasks 3. Mark Complete 4. Delete Task 5. Exit Choose an option: _ ``` When the task list is empty: ```text Your Tasks: No tasks yet. Use option 1 to add a task. ```

[!TIP] Pro-Tip: Show Edge Cases Including edge cases (like empty states) in your code blocks gives AI a concrete target for handling those scenarios. If you don't show what "empty" looks like, the AI might not handle it gracefully.

Part 2: Update Installation Commands

markdown
## Installation 1. Install Python 3.9 or higher from python.org 2. Download the task tracker files from GitHub 3. Navigate to the project folder: `cd task-tracker` 4. Run the program: `python tracker.py`

Common Mistakes to Avoid

Mistake 1: Forgetting Closing Backticks

Always close your code blocks with triple backticks — everything after an unclosed block becomes part of the code block.

Mistake 2: Using Inline Code for Multiple Lines

Use fenced blocks for anything longer than a single short reference.

Mistake 3: No Language Tag When It Matters

bash
pip install requests

Adding bash makes it clear this is a terminal command, not Python code or plain text.


Try With AI

Prompt 1 (Structure Check):

markdown
I'm learning code blocks in markdown. Can you check if I used the right syntax? [Paste your specification here] Tell me: 1. Are my code blocks properly closed? 2. Did I use appropriate language tags? 3. Should any inline code be fenced blocks instead?

Prompt 2 (Clarity Check):

markdown
Based on my specification, can you tell: 1. What should the program output look like? 2. What programming language is this written in? 3. What commands need to be run?

Prompt 3 (Implementation + Execution Test):

markdown
Can you implement a simple version of this Task Tracker App specification? Generate Python code that shows the main menu and displays sample tasks like I specified in the Expected Output section.