﻿{
    "cells":  [
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "# Module 5 Self-Driven Lab\n",
                                     "\n",
                                     "Use this notebook as your workspace for **Claude Code \u0026 Repository Context**. The answer-key notebook sits next to this file. Work through each checkpoint before comparing against the completed version.\n"
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "# Module 5 â€” Claude Code \u0026 Repository Context\n",
                                     "\n",
                                     "This module is about the Claude Code CLI rather than the Python SDK. The cells below scaffold the three patterns architects need: **path-scoped rules** in `.claude/rules/`, **agent skills** with isolated context, and **non-interactive CI/CD execution** with the `-p` flag.\n",
                                     "\n",
                                     "Each cell writes a config file into a `module5_demo/` folder so you can inspect the structure without touching your real project."
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## 1. Path-scoped rule (`.claude/rules/brand-voice.md`)\n",
                                     "\n",
                                     "YAML frontmatter with `globs` ensures these instructions only enter Claude\u0027s context when working on matched files â€” keeps the context window focused."
                                 ]
                  },
                  {
                      "cell_type":  "code",
                      "execution_count":  null,
                      "metadata":  {

                                   },
                      "outputs":  [

                                  ],
                      "source":  [
                                     "# Setup cell. Run this before the exercise cells below.\n",
                                     "from pathlib import Path\n",
                                     "\n",
                                     "rules_dir = Path(\"module5_demo/.claude/rules\")\n",
                                     "rules_dir.mkdir(parents=True, exist_ok=True)\n",
                                     "\n",
                                     "(rules_dir / \"brand-voice.md\").write_text(\n",
                                     "    \"\"\"---\n",
                                     "globs: [\"whitepapers/**/*.md\", \"blog/**/*.md\"]\n",
                                     "---\n",
                                     "# Brand Voice Rules\n",
                                     "- Never use industry jargon without defining it.\n",
                                     "- Always highlight the \\\"AI-human partnership\\\" in every conclusion.\n",
                                     "- Maintain a professional yet accessible tone.\n",
                                     "\"\"\",\n",
                                     "    encoding=\"utf-8\",\n",
                                     ")\n",
                                     "\n",
                                     "print(\"wrote\", rules_dir / \"brand-voice.md\")"
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## 2. Agent skill with `context: fork`\n",
                                     "\n",
                                     "`context: fork` runs the skill in an isolated execution environment so verbose output (e.g. a full competitor scrape) doesn\u0027t pollute your main strategy session.\n",
                                     "\n",
                                     "\u003e **ZDR note:** Agent Skills are **not ZDR-eligible**."
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## Checkpoint 1\n",
                                     "\n",
                                     "Implement this step yourself. Use the preceding explanation and the module page as your guide, then compare your approach with the answer key after you have a working version.\n"
                                 ]
                  },
                  {
                      "cell_type":  "code",
                      "execution_count":  null,
                      "metadata":  {

                                   },
                      "outputs":  [

                                  ],
                      "source":  [
                                     "# TODO: Implement checkpoint 1 for Module 5.\n",
                                     "# Keep the cell focused, run it, inspect the output, then move to the next checkpoint.\n",
                                     "\n",
                                     "raise NotImplementedError(\u0027Complete checkpoint 1\u0027)\n"
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## 3. CI/CD invocation\n",
                                     "\n",
                                     "`-p` is print mode: Claude runs non-interactively so the pipeline never hangs waiting for input. `--output-format json` produces structured output you can pipe into downstream automation. The cell below just prints the command â€” run it in your CI step, not from this notebook."
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## Checkpoint 2\n",
                                     "\n",
                                     "Implement this step yourself. Use the preceding explanation and the module page as your guide, then compare your approach with the answer key after you have a working version.\n"
                                 ]
                  },
                  {
                      "cell_type":  "code",
                      "execution_count":  null,
                      "metadata":  {

                                   },
                      "outputs":  [

                                  ],
                      "source":  [
                                     "# TODO: Implement checkpoint 2 for Module 5.\n",
                                     "# Keep the cell focused, run it, inspect the output, then move to the next checkpoint.\n",
                                     "\n",
                                     "raise NotImplementedError(\u0027Complete checkpoint 2\u0027)\n"
                                 ]
                  },
                  {
                      "cell_type":  "markdown",
                      "metadata":  {

                                   },
                      "source":  [
                                     "## Reflection\n",
                                     "\n",
                                     "Before opening the answer key, write down what worked, what failed, and which API behavior or agent-design rule you would rely on in production.\n"
                                 ]
                  }
              ],
    "metadata":  {
                     "kernelspec":  {
                                        "display_name":  "Python 3",
                                        "language":  "python",
                                        "name":  "python3"
                                    },
                     "language_info":  {
                                           "name":  "python",
                                           "version":  "3.9"
                                       }
                 },
    "nbformat":  4,
    "nbformat_minor":  5
}
