Skip to content

C. Makefile & Automation

📄 File 3: docs/appendix-makefile-reference.md

# Appendix C: Makefile & Automation Reference

This appendix explains how to read and use the `Makefile` provided in this book's repository, turning complex Aider commands into simple, repeatable workflows.

## 1. What is `make`?
`make` is a build automation tool that reads a `Makefile` to execute predefined sequences of shell commands (called "targets"). It ensures that complex, multi-step AI workflows are executed consistently, without typos.

## 2. Anatomy of the Book's Makefile

The `Makefile` in this repository is structured into logical sections:

```makefile
# 1. Variables (Easy to override)
CHAPTER ?= 02
AIDER_EDITOR ?= qwen-2.5-coder

# 2. Targets (The commands you run)
improve-chapter:
    @echo "Improving chapter..."
    aider --model $(AIDER_EDITOR) --read AGENTS.md --message "Improve this..."

3. Common Targets & How to Use Them

Command What it Does When to Use
make help Prints all available commands and current configuration. Whenever you forget a command.
make validate Runs scripts/validate-aibook-guardrails.py. Before and after any AI modification.
make cost-check CHAPTER=03 Estimates the token cost of a specific chapter. Always before running improve-chapter.
make improve-chapter CHAPTER=03 Uses Tier 2 (Qwen) to surgically improve the chapter. Daily writing and refinement.
make review-chapter CHAPTER=03 Uses Tier 1 (DeepSeek) to deeply review the chapter. Final polish before publishing a release.
make evolve Runs validate, and if it fails, runs fix-validation. When you want a fully autonomous self-healing loop.

4. How to Override Variables

You don't need to edit the Makefile to change its behavior. You can pass variables directly in the terminal:

# Override the chapter to work on Chapter 04
make improve-chapter CHAPTER=04

# Override the model to use a premium Architect model for a complex rewrite
make improve-chapter CHAPTER=02 AIDER_EDITOR=deepseek-chat

# Combine overrides
make cost-check CHAPTER=05

5. The "Dogfooding" Daily Workflow

As the author of this book, this is the exact sequence I use to write it:

# 1. Check the cost of the chapter I'm about to work on
make cost-check CHAPTER=02

# 2. Ask the Tier 2 Editor to improve clarity and flow
make improve-chapter CHAPTER=02

# 3. Verify the AI didn't break the Markdown structure or delete key sections
make validate

# 4. Review the changes safely
git diff docs/02-repo-cli-ai.md

# 5. If happy, commit the changes
make commit-improvements

🔗 Return to Chapter 2: Building a Self-Improving Repository Workflow

---

### Step 4: Update Your `mkdocs.yml`

To make these easily discoverable via the MkDocs search bar and navigation, add an **Appendices** section to the bottom of your `nav` list in `mkdocs.yml`:

```yaml
nav:
  - Home: index.md
  - AI Foundations for DevOps: 01-introduction.md
  - The Self-Improving Repository: 02-repo-cli-ai.md
  - IaC Using AI: 03-iac-using-ai.md
  - App Service Deployment: 04-app-service-deployment.md
  - CI/CD Pipeline: 05-cicd-pipeline.md
  - Production Deployment: 06-production-deployment.md
  - Governance & Safety: 07-governance-safety.md
  - Monitoring & Observability: 08-monitoring-observability.md
  - Continuous Improvement: 09-continuous-improvement.md
  - AI Agent: 10-ai-agent.md
  - Publisher Readiness Rubric: publisher-readiness-rubric.md

  # --- NEW APPENDICES SECTION ---
  - Appendices:
    - A. Aider Quick Reference: appendix-aider-reference.md
    - B. Hugging Face & Local Models: appendix-huggingface-reference.md
    - C. Makefile & Automation: appendix-makefile-reference.md

Why This Elevates Your Book

  1. Zero Context Switching: The reader never has to leave your beautifully rendered MkDocs site to figure out what huggingface-cli download does.
  2. Searchability: MkDocs Material's search is incredibly fast. A reader typing "switch model" will instantly land on Appendix A.
  3. Publisher Credibility: Including dedicated reference appendices is a hallmark of professional, O'Reilly-style technical books. It shows you aren't just writing a tutorial; you are building a complete, self-sustaining knowledge base.

Would you like me to help you run the make commit-improvements and make publish commands now to lock in all these structural enhancements?