Module 5

Claude Code & Repository Context

The Claude Code CLI operates directly in your terminal as an agentic coding assistant. This module covers the three patterns architects need for production workflows: path-scoped rules, agent skills with isolated context, and non-interactive CI/CD execution.

Answer key Module5_Complete.ipynb

1. The CLAUDE.md Hierarchy

CLAUDE.md provides persistent, project-level instructions without bloating every system prompt. Claude loads the file when entering a relevant directory.

  • User-level: Applies across all your projects on one machine.
  • Project-level: Rules for your entire consulting repository (e.g., "Always use Python for automation scripts").
  • Directory-level: Rules scoped to a specific subfolder, a CLAUDE.md inside /marketing overrides the project-level file for that path.

2. Path-Scoped Rules with .claude/rules/

Instead of a monolithic CLAUDE.md, use the .claude/rules/ directory to define rules that load only when Claude is working on specific file paths. Each file uses YAML frontmatter with a globs key.

Markdown (.claude/rules/brand-voice.md)
---
globs: ["whitepapers/**/*.md", "blog/**/*.md"]
---
# Brand Voice Rules
- Never use industry jargon without defining it.
- Always highlight the "AI-human partnership" in every conclusion.
- Maintain a professional yet accessible tone.
Architect Tip

The globs field ensures these rules are only injected into context when Claude is working on the matched paths, keeping the context window focused and cost-efficient.

3. Agent Skills (context: fork)

Agent Skills are modular, on-demand resources that package instructions, scripts, and templates. Each skill lives in a directory containing a SKILL.md file with YAML frontmatter.

  • context: fork, Isolates the skill's execution environment from your main strategy session. Verbose research output (e.g., a full competitor scrape) won't pollute your primary context window.
  • allowed-tools, Restricts which tools a skill can access.
  • ZDR note: Agent Skills are not ZDR-eligible, data used within skills follows standard retention policies.
YAML (SKILL.md frontmatter)
---
name: competitor-research
description: Scrapes and summarizes competitor pricing pages
context: fork          # isolate from main session
allowed-tools: [web_search, web_fetch]
---
# Competitor Research Skill
1. Search for the target company's pricing page.
2. Fetch the full page content.
3. Return a structured JSON summary of their tiers and prices.

4. CI/CD Integration: The -p Flag

To run Claude Code in automated pipelines (GitHub Actions, Jenkins) without interactive prompts:

  • -p flag, "Print" mode. Executes Claude non-interactively and prevents pipeline hangs caused by waiting for user input.
  • --output-format json, Returns Claude's actions as structured JSON for piping into downstream automation.
bash (CI/CD pipeline step)
# Non-interactive execution, safe in CI/CD
claude -p "Run the SEO audit skill on /blog and output findings" \
  --output-format json > audit-results.json

Lab Exercise: Repository Governance with Claude Code

Self-driven lab Module5_Self_Driven_Lab.ipynb

Objective: turn project standards into durable Claude Code configuration.

  1. Draft a project-level `CLAUDE.md` that defines the agent project standards.
  2. Create a path-scoped rule for outreach or CRM code.
  3. Sketch an Agent Skill that runs in a forked context for compliance review.
  4. Write the CI command or prompt pattern that would run the review non-interactively.
Expected Deliverable

A repository governance package for the agent project.