← Study Guide
DOMAIN 320% of exam

Claude Code Configuration & Workflows

CLAUDE.md hierarchy and modular organization, custom slash commands and skills, path-specific rules, plan mode vs direct execution, iterative refinement, and CI/CD integration.

Key Takeaways

  • 1.Project-scoped config (.claude/commands/, .claude/rules/, root CLAUDE.md) is shared via version control; user-scoped (~/.claude/…) is personal only.
  • 2..claude/rules/ with paths: glob frontmatter beats directory CLAUDE.md when conventions span many directories (e.g., test files everywhere).
  • 3.Plan mode = complex/architectural/multi-file/multiple-approaches. Direct execution = simple, well-scoped changes.
  • 4.In CI: -p / --print for non-interactive; --output-format json + --json-schema for machine-parseable findings.

Task Statements (6)

▶ click any point to expand details, examples & exam tips

3.1

Configure CLAUDE.md files with hierarchy, scoping, and modular organization

Knowledge of

  • Hierarchy: user (~/.claude/CLAUDE.md) → project (.claude/CLAUDE.md or root CLAUDE.md) → directory-level.

    CLAUDE.md files load at multiple levels. User-level applies to just you across all projects; project-level ships with the repo for everyone; directory-level applies within a subtree. More specific levels layer on top of broader ones.

    CLAUDE.md فائلیں کئی سطحوں پر لوڈ ہوتی ہیں۔ یوزر لیول صرف آپ پر سب پروجیکٹس میں لاگو؛ پروجیکٹ لیول repo کے ساتھ سب کے لیے آتا ہے؛ ڈائریکٹری لیول ایک ذیلی حصے میں لاگو۔ زیادہ خاص سطحیں وسیع سطحوں کے اوپر لگتی ہیں۔

    LevelLocationApplies to
    User~/.claude/CLAUDE.mdOnly you, all your projects
    Project.claude/CLAUDE.md or root CLAUDE.mdEveryone on the repo
    Directory<subdir>/CLAUDE.mdWork within that subtree
  • User-level settings apply only to that user — NOT shared with teammates via VCS.

    ~/.claude/CLAUDE.md lives in your home directory, not the repo. If a teammate isn't getting an instruction, it may be stuck in someone's user-level config instead of the project.

    ~/.claude/CLAUDE.md آپ کی ہوم ڈائریکٹری میں ہوتی ہے، repo میں نہیں۔ اگر کسی ساتھی کو کوئی ہدایت نہیں مل رہی، تو شاید وہ پروجیکٹ کے بجائے کسی کے یوزر لیول کنفیگ میں پھنسی ہے۔

    Exam tip: Teammate not receiving an instruction? It's probably in user-level config; move it to project-level.
  • The @import syntax for referencing external files to keep CLAUDE.md modular.

    @import pulls another file's content into CLAUDE.md, so you can keep a small root file that includes only the standards relevant to each package.

    @import کسی اور فائل کا مواد CLAUDE.md میں لے آتا ہے، تاکہ آپ ایک چھوٹی اصل فائل رکھ سکیں جو ہر package کے صرف متعلقہ اصول شامل کرے۔

    # CLAUDE.md
    @import ./standards/testing.md
    @import ./standards/api-conventions.md
  • .claude/rules/ directory for organizing topic-specific rule files as an alternative to a monolithic CLAUDE.md.

    Instead of one giant CLAUDE.md, split rules into focused files (testing.md, deployment.md) under .claude/rules/. Easier to maintain and can be path-scoped (see Task 3.3).

    ایک بڑی CLAUDE.md کے بجائے قواعد کو مرکوز فائلوں میں بانٹیں (testing.md، deployment.md) .claude/rules/ کے تحت۔ سنبھالنا آسان اور راستے تک محدود کیا جا سکتا ہے (Task 3.3 دیکھیں)۔

Skills in

  • Diagnose hierarchy issues (a teammate missing instructions because they live in user-level, not project-level, config).

    When behavior differs person-to-person, trace WHICH file the instruction lives in. A rule in someone's ~/.claude/CLAUDE.md never reaches teammates; moving it to the repo's project-level file fixes the inconsistency.

    جب رویّہ ہر شخص پر الگ ہو، تو دیکھیں ہدایت کس فائل میں پڑی ہے۔ کسی کے ~/.claude/CLAUDE.md میں پڑا اصول ساتھیوں تک کبھی نہیں پہنچتا؛ اسے repo کی پروجیکٹ لیول فائل میں لے جانا یہ فرق ختم کر دیتا ہے۔

    /memory shows the loaded files:
      ~/.claude/CLAUDE.md   (user - only you)
      ./CLAUDE.md           (project - everyone)
    // "use conventional commits" is only in the USER file
    // -> teammates never get it; move it into ./CLAUDE.md
  • Use @import to selectively include relevant standards per package based on maintainer domain knowledge.

    Keep the root CLAUDE.md small and pull in only the standards each package needs via @import. Maintainers decide which standard files apply, so context stays relevant instead of dumping everything everywhere.

    اصل CLAUDE.md چھوٹی رکھیں اور ہر package کے صرف ضروری اصول @import سے لائیں۔ سنبھالنے والے طے کریں کون سی اصول فائلیں لاگو ہوں، تاکہ سیاق متعلقہ رہے، ہر جگہ سب کچھ ٹھونسنے کے بجائے۔

    # CLAUDE.md
    @import ./standards/testing.md
    @import ./standards/api-conventions.md
  • Split a large CLAUDE.md into .claude/rules/ topic files (testing.md, api-conventions.md, deployment.md).

    A monolithic CLAUDE.md is hard to maintain and always fully loaded. Breaking it into focused rule files is easier to edit and lets each file be path-scoped so it loads only when relevant (Task 3.3).

    ایک بڑی CLAUDE.md سنبھالنا مشکل اور ہمیشہ پوری لوڈ رہتی ہے۔ اسے مرکوز rule فائلوں میں توڑنا ایڈٹ کرنا آسان کرتا ہے اور ہر فائل کو راستے تک محدود کرنے دیتا ہے تاکہ صرف متعلقہ ہونے پر لوڈ ہو (Task 3.3)۔

    // before: one 400-line CLAUDE.md, always fully loaded
    // after:
    .claude/rules/testing.md          (paths: ["**/*.test.*"])
    .claude/rules/api-conventions.md
    .claude/rules/deployment.md
    // each focused, editable, and path-scoped to load only when relevant
  • Use the /memory command to verify which memory files are loaded and diagnose inconsistent behavior across sessions.

    /memory shows exactly which CLAUDE.md / rule files are currently loaded — the fastest way to explain why behavior differs between sessions or machines.

    /memory ٹھیک بتاتا ہے اس وقت کون سی CLAUDE.md / rule فائلیں لوڈ ہیں — یہ جاننے کا تیز ترین طریقہ کہ سیشنز یا مشینوں کے درمیان رویّہ کیوں مختلف ہے۔

    /memory
    LOADED:
      ~/.claude/CLAUDE.md
      /repo/CLAUDE.md
      /repo/.claude/rules/testing.md   (matched **/*.test.ts)
    // explains why THIS session behaves differently from another machine's

Edge Cases & Traps

  • If teammates behave differently, check whether the instruction lives in user scope (not shared) vs project scope (shared).
3.2

Create and configure custom slash commands and skills

Knowledge of

  • Project commands in .claude/commands/ (shared via VCS) vs user commands in ~/.claude/commands/ (personal).

    A slash command every developer should have on clone/pull goes in the project's .claude/commands/. Personal-only commands go in ~/.claude/commands/.

    جو slash command ہر ڈیولپر کو clone/pull پر ملنی چاہیے وہ پروجیکٹ کے .claude/commands/ میں جاتی ہے۔ صرف ذاتی کمانڈز ~/.claude/commands/ میں۔

    Exam tip: "Available to every developer on clone/pull" ⇒ .claude/commands/ (project), not ~/.claude/commands/, not CLAUDE.md.
  • Skills in .claude/skills/ with SKILL.md frontmatter: context: fork, allowed-tools, argument-hint.

    Skills are on-demand workflows defined by a SKILL.md whose frontmatter configures how they run — isolate them, restrict their tools, and prompt for arguments.

    Skills ضرورت پر چلنے والے کام ہیں جو SKILL.md سے بنتے ہیں، جس کا frontmatter طے کرتا ہے وہ کیسے چلیں — انہیں الگ کریں، ٹول محدود کریں، اور دلائل (arguments) مانگیں۔

    ---
    name: analyze-codebase
    context: fork          # run isolated, don't pollute main chat
    allowed-tools: [Read, Grep, Glob]
    argument-hint: <path>  # prompt if invoked with no arg
    ---
  • context: fork runs a skill in an isolated sub-agent context so its output doesn't pollute the main conversation.

    Verbose skills (codebase analysis) or exploratory ones (brainstorming) produce lots of output. context: fork runs them in a separate context and returns just the result, keeping the main session clean.

    لمبی skills (کوڈ کا تجزیہ) یا کھوجی skills (brainstorming) بہت آؤٹ پٹ دیتی ہیں۔ context: fork انہیں الگ سیاق میں چلا کر صرف نتیجہ واپس دیتا ہے، اور اصل سیشن صاف رکھتا ہے۔

    Exam tip: Skill produces verbose/exploratory output you don't want in the main chat ⇒ context: fork.
  • Personal skill customization: creating variants in ~/.claude/skills/ with different names to avoid affecting teammates.

    Want a tweaked version of a shared skill just for you? Put a differently-named variant in ~/.claude/skills/ so teammates' behavior is untouched.

    کسی مشترکہ skill کا اپنے لیے بدلا ہوا نسخہ چاہیے؟ الگ نام والا نسخہ ~/.claude/skills/ میں رکھیں تاکہ ساتھیوں کا رویّہ نہ بدلے۔

Skills in

  • Create project-scoped slash commands in .claude/commands/ for team-wide availability via VCS.

    Anything every developer should have the moment they clone or pull belongs in the project's .claude/commands/ — it's committed and shared. Personal-only commands go in ~/.claude/commands/ instead.

    جو چیز ہر ڈیولپر کو clone/pull کرتے ہی ملنی چاہیے وہ پروجیکٹ کے .claude/commands/ میں ہوتی ہے — یہ commit اور شیئر ہوتا ہے۔ صرف ذاتی کمانڈز اس کے بجائے ~/.claude/commands/ میں۔

    // committed -> every dev gets /deploy-check on pull
    .claude/commands/deploy-check.md
    // a personal-only command would instead live in:
    ~/.claude/commands/my-scratch.md
  • Use context: fork to isolate skills that produce verbose (codebase analysis) or exploratory (brainstorming) output.

    A skill that generates a wall of discovery output would bury the main conversation. context: fork runs it in a separate sub-agent context and returns only the result, keeping your working session clean.

    جو skill کھوج کا ڈھیر آؤٹ پٹ بناتی ہے وہ اصل گفتگو کو دبا دیتی ہے۔ context: fork اسے الگ چھوٹے ایجنٹ کے سیاق میں چلا کر صرف نتیجہ واپس دیتا ہے، اور آپ کا کام کرنے والا سیشن صاف رہتا ہے۔

    ---
    name: analyze-codebase
    context: fork      # runs in a separate sub-agent context
    ---
    // its wall of discovery output stays OUT of the main chat;
    // only the final summary returns
  • Configure allowed-tools in skill frontmatter to restrict tool access during execution (e.g., limit to file writes to prevent destructive actions).

    Scope a skill to just the tools it needs so it can't take actions outside its job. A read-only analysis skill given only Read/Grep/Glob physically cannot modify or delete files.

    کسی skill کو صرف اس کے ضروری ٹول تک محدود کریں تاکہ وہ اپنے کام سے باہر کوئی عمل نہ کر سکے۔ صرف پڑھنے والی تجزیہ skill جسے صرف Read/Grep/Glob دیے ہوں، فائلیں بدل یا مٹا ہی نہیں سکتی۔

    ---
    name: audit-code
    context: fork
    allowed-tools: [Read, Grep, Glob]   # no Write/Bash -> can't mutate anything
    ---
  • Use argument-hint to prompt developers for required parameters when they invoke the skill without arguments.

    argument-hint documents the expected input and makes Claude ask for it when a developer runs the skill bare — so a skill that needs a path doesn't silently guess or fail.

    argument-hint متوقع ان پٹ بتاتا ہے اور جب ڈیولپر skill بغیر دلیل کے چلائے تو Claude سے وہ مانگواتا ہے — تاکہ راستہ مانگنے والی skill خاموشی سے اندازہ نہ لگائے یا ناکام نہ ہو۔

    ---
    name: review-file
    argument-hint: <path>       # prompts when invoked bare
    ---
    /review-file             -> Claude asks: "which file/path?"
    /review-file src/api.ts  -> runs directly
  • Choose between skills (on-demand, task-specific) and CLAUDE.md (always-loaded universal standards).
    MechanismLoadingUse for
    SkillOn-demand (invoked)Task-specific workflows
    CLAUDE.mdAlways loadedUniversal standards / context

Edge Cases & Traps

  • A command that must reach every developer belongs in .claude/commands/ (project), NOT ~/.claude/commands/ (personal) and NOT in CLAUDE.md (that's context, not command definitions).
  • .claude/config.json with a commands array does not exist — distractor.
3.3

Apply path-specific rules for conditional convention loading

Knowledge of

  • .claude/rules/ files use YAML paths: glob patterns for conditional activation.

    A rule file's frontmatter can declare which file paths it applies to. The rule loads only when you're editing a matching file, so unrelated context stays out of the way and tokens are saved.

    rule فائل کا frontmatter بتا سکتا ہے یہ کن راستوں پر لاگو ہے۔ اصول صرف تب لوڈ ہوتا ہے جب آپ ملتی فائل ایڈٹ کر رہے ہوں، تاکہ غیر متعلقہ سیاق راستے سے ہٹا رہے اور ٹوکن بچیں۔

    ---
    paths: ["**/*.test.tsx", "**/*.test.ts"]
    ---
    # Testing conventions (loaded only when editing test files)
    - Use React Testing Library...
  • Path-scoped rules load only when editing matching files — less irrelevant context, fewer tokens.
  • Glob rules beat directory CLAUDE.md when conventions span multiple directories.

    Directory CLAUDE.md is bound to one folder. When the files you care about (tests, terraform, all *.tsx) are scattered across the tree, a glob-scoped rule applies by TYPE regardless of location — which a directory file cannot do.

    ڈائریکٹری CLAUDE.md ایک فولڈر تک بندھی ہوتی ہے۔ جب آپ کی مطلوبہ فائلیں (ٹیسٹ، terraform، سارے *.tsx) ٹری میں بکھری ہوں، تو glob والا اصول قسم کے حساب سے لاگو ہوتا ہے، جگہ کوئی بھی ہو — جو ڈائریکٹری فائل نہیں کر سکتی۔

    Exam tip: Convention must apply to files spread across many directories (e.g., all test files) ⇒ .claude/rules/ with globs, not directory CLAUDE.md.

Skills in

  • Create rules with paths: ["terraform/**/*"] so they load only on matching files.

    Put the glob in the rule's frontmatter and the conventions activate only while editing matching files — so Terraform standards don't consume context when you're in application code.

    glob کو rule کے frontmatter میں رکھیں تو اصول صرف ملتی فائلیں ایڈٹ کرتے وقت فعال ہوتے ہیں — تاکہ Terraform کے اصول تب سیاق نہ کھائیں جب آپ ایپلیکیشن کوڈ میں ہوں۔

    ---
    paths: ["terraform/**/*"]
    ---
    # Terraform conventions (loaded only for IaC files)
  • Apply conventions by file TYPE regardless of location (**/*.test.tsx for all tests).

    A glob matches by pattern anywhere in the tree, so a single rule covers every test file no matter which feature folder it sits in — something a directory-bound CLAUDE.md can't achieve.

    glob پورے ٹری میں نمونے سے ملاتا ہے، اس لیے ایک ہی اصول ہر ٹیسٹ فائل کو ڈھانپ لیتا ہے چاہے وہ کسی بھی feature فولڈر میں ہو — جو فولڈر تک بندھی CLAUDE.md نہیں کر سکتی۔

    ---
    paths: ["**/*.test.tsx"]       # matches anywhere in the tree
    ---
    # loads for src/a/x.test.tsx AND src/z/y.test.tsx
    # a directory CLAUDE.md could only cover ONE folder
  • Choose path rules over subdirectory CLAUDE.md when files are spread across the codebase.

    Directory CLAUDE.md only applies within its folder. When the files sharing a convention are scattered (tests, *.tsx, IaC), glob-scoped rules load automatically and deterministically by type — the right tool over a directory file, an optional skill, or inference from a monolith.

    ڈائریکٹری CLAUDE.md صرف اپنے فولڈر میں لاگو ہوتی ہے۔ جب ایک اصول والی فائلیں بکھری ہوں (ٹیسٹ، *.tsx، IaC)، تو glob والے اصول قسم کے حساب سے خودبخود اور پکے طور پر لوڈ ہوتے ہیں — ڈائریکٹری فائل، اختیاری skill، یا بڑی فائل سے اندازے کے مقابلے صحیح آلہ۔

    Files scattered by TYPE (tests, *.tsx, IaC)? -> .claude/rules/ + globs (auto)
    All files in ONE folder?                     -> directory CLAUDE.md is fine
    // don't rely on a monolith's inference or an optional skill for this

Edge Cases & Traps

  • For test files spread throughout a codebase, glob rules are the automatic, deterministic choice — directory CLAUDE.md files are directory-bound; skills require manual/optional loading; a monolithic CLAUDE.md relies on inference.
3.4

Determine when to use plan mode vs direct execution

Knowledge of

  • Plan mode: large-scale changes, multiple valid approaches, architectural decisions, multi-file edits.

    Plan mode explores and designs before touching code. It's for work where a wrong early decision is expensive — restructuring, migrations, choosing between approaches — so you validate the plan first.

    Plan mode کوڈ کو ہاتھ لگانے سے پہلے کھوج اور ڈیزائن کرتا ہے۔ یہ اُس کام کے لیے ہے جہاں شروع کا غلط فیصلہ مہنگا پڑے — ڈھانچہ بدلنا، migration، طریقوں میں سے چننا — تاکہ پہلے منصوبہ جانچ لیا جائے۔

    SignalMode
    Multi-file / architectural / multiple approachesPlan mode
    Single-file, clear scope, known fixDirect execution
  • Direct execution: simple, well-scoped changes (a single validation check).

    When the change is small and the path is obvious (a one-line fix with a clear stack trace), planning is overhead — just do it.

    جب تبدیلی چھوٹی ہو اور راستہ صاف ہو (ایک لائن کا حل، صاف stack trace کے ساتھ)، تو منصوبہ بندی فالتو بوجھ ہے — بس کر دیں۔

  • Plan mode enables safe codebase exploration and design before committing to changes, preventing costly rework.
  • The Explore subagent isolates verbose discovery output and returns summaries to preserve main-conversation context.

    During a multi-phase task, discovery generates a lot of noise. The Explore subagent does that digging in its own context and hands back a concise summary, so the main session doesn't fill up.

    کئی مرحلوں والے کام میں کھوج بہت شور پیدا کرتی ہے۔ Explore ایجنٹ وہ کھدائی اپنے سیاق میں کرتا ہے اور ایک مختصر خلاصہ واپس دیتا ہے، تاکہ اصل سیشن نہ بھرے۔

Skills in

  • Plan mode for architectural work (microservice restructuring, a 45+ file library migration, choosing integration approaches).

    When a wrong early decision is expensive — many files, service boundaries, or several viable approaches — explore and design first, then validate the plan before writing code. That upfront investment prevents costly rework.

    جب شروع کا غلط فیصلہ مہنگا ہو — کئی فائلیں، سروس کی حدیں، یا کئی ممکن طریقے — تو پہلے کھوج اور ڈیزائن کریں، پھر کوڈ لکھنے سے پہلے منصوبہ جانچیں۔ یہ شروع کی محنت بعد کی مہنگی دوبارہ محنت سے بچاتی ہے۔

    "Migrate 45 files from lib v1 -> v2" / "split the monolith into services"
    -> Plan mode: explore, design, validate the plan BEFORE editing
    // a wrong early decision here is expensive to undo
  • Direct execution for clear-scope changes (single-file bug fix with a stack trace, adding a date conditional).

    When the scope is small and the fix is obvious, planning is pure overhead — just make the change. A stack trace pointing at one function is a direct-execution job.

    جب دائرہ چھوٹا اور حل صاف ہو، تو منصوبہ بندی خالص فالتو بوجھ ہے — بس تبدیلی کر دیں۔ ایک فنکشن کی طرف اشارہ کرتا stack trace سیدھے کرنے والا کام ہے۔

    Stack trace -> TypeError at cart.py:88, off-by-one in the loop
    -> Direct execution: just fix it
    // planning a one-line, obvious fix is pure overhead
  • Use the Explore subagent for verbose discovery phases to avoid context window exhaustion.

    Discovery generates a lot of noise. Delegating it to the Explore subagent keeps that digging in a separate context and returns a concise summary, so the main session's window isn't consumed by file dumps.

    کھوج بہت شور پیدا کرتی ہے۔ اسے Explore ایجنٹ کو سونپنا وہ کھدائی الگ سیاق میں رکھتا ہے اور ایک مختصر خلاصہ لوٹاتا ہے، تاکہ اصل سیشن کا window فائلوں کے ڈھیر سے نہ بھرے۔

    Task(Explore, "map the auth module: entrypoints, deps, callers")
    // the digging happens in Explore's OWN context;
    // the main session receives a concise summary, not the file dumps
  • Combine plan mode for investigation with direct execution for implementation (plan the migration, then execute the planned approach).

    The two modes aren't exclusive: plan the risky, ambiguous migration first, then switch to direct execution to carry out each well-defined step of the approved plan.

    دونوں طریقے ایک دوسرے کے مخالف نہیں: پہلے خطرناک، مبہم migration کا منصوبہ بنائیں، پھر منظور شدہ منصوبے کے ہر صاف قدم کو کرنے کے لیے سیدھے عمل پر آ جائیں۔

    1. Plan mode:      design the v1 -> v2 migration (risky, ambiguous)
    2. Direct execute: carry out each well-defined step of the approved plan
    // plan the hard part, execute the clear part

Edge Cases & Traps

  • If the requirements already state the complexity (dozens of files, service boundaries), don't 'start direct and switch later' — the complexity isn't hypothetical.
3.5

Apply iterative refinement techniques for progressive improvement

Knowledge of

  • Concrete input/output examples beat prose when descriptions are interpreted inconsistently.

    When a prose spec keeps producing inconsistent results, stop describing and start showing. 2–3 concrete input→output pairs pin down the exact transformation you want.

    جب عبارت والی وضاحت بار بار الگ الگ نتیجہ دے، تو بیان کرنا چھوڑ کر دکھانا شروع کریں۔ ۲-۳ ٹھوس ان پٹ←آؤٹ پٹ جوڑے وہ عین تبدیلی طے کر دیتے ہیں جو آپ چاہتے ہیں۔

  • Test-driven iteration: write tests first, then iterate by sharing failures.

    Write a test suite covering behavior, edge cases, and performance up front, then iterate by feeding Claude the failing test output. Failures are precise, actionable feedback.

    پہلے ایسا ٹیسٹ سیٹ لکھیں جو رویّہ، خاص صورتیں اور کارکردگی ڈھانپے، پھر Claude کو ناکام ٹیسٹ کا نتیجہ دے کر بہتری کریں۔ ناکامیاں صاف، قابلِ عمل رائے ہوتی ہیں۔

  • Interview pattern: have Claude ask questions to surface considerations before implementing.

    For unfamiliar domains, ask Claude to interview YOU first — it surfaces edge cases (cache invalidation, failure modes) you hadn't specified, before writing code.

    اجنبی موضوعات میں پہلے Claude سے کہیں کہ وہ آپ کا انٹرویو لے — یہ کوڈ لکھنے سے پہلے ایسی خاص صورتیں (cache invalidation، ناکامی کی حالتیں) سامنے لاتا ہے جو آپ نے نہیں بتائی تھیں۔

  • Provide interacting problems together in one message; fix independent problems sequentially.

    If two bugs interact, describing both at once lets the model reason about their interaction. Independent issues can be handled one at a time.

    اگر دو خرابیاں آپس میں جڑی ہوں تو دونوں ایک ساتھ بتانا ماڈل کو ان کے تعلق پر سوچنے دیتا ہے۔ الگ الگ مسئلے ایک ایک کر کے سنبھالے جا سکتے ہیں۔

    Problem relationshipHow to report
    Interacting / coupledAll in ONE detailed message
    IndependentSequentially, one at a time

Skills in

  • Give 2–3 concrete input/output examples to clarify transformations.

    When a prose description keeps getting interpreted differently, stop describing and start showing. A couple of input→output pairs pin the exact transformation far more reliably than more adjectives.

    جب عبارت والی وضاحت بار بار الگ سمجھی جائے، تو بیان کرنا چھوڑ کر دکھانا شروع کریں۔ چند ان پٹ←آؤٹ پٹ جوڑے مزید صفتوں کے مقابلے عین تبدیلی کہیں زیادہ بھروسے سے طے کر دیتے ہیں۔

    in:  "2024-01-05"        out: "Jan 5, 2024"
    in:  "2024-12-31"        out: "Dec 31, 2024"
    in:  null                 out: "—"   # shows the null case too
  • Write test suites (behavior, edge cases, performance) before implementation, then iterate on failures.

    Tests written first become precise, actionable feedback: share the failing output and Claude has an exact target to fix, instead of you re-describing the requirement each round.

    پہلے لکھے ٹیسٹ صاف، قابلِ عمل رائے بن جاتے ہیں: ناکام نتیجہ دے دیں تو Claude کے پاس ٹھیک کرنے کا واضح ہدف ہوتا ہے، بجائے اس کے کہ آپ ہر بار تقاضا دوبارہ بیان کریں۔

    # write the tests first (they fail):
    test_parses_iso()     -> FAIL
    test_handles_null()   -> FAIL
    # share the failing output; Claude gets an exact target to fix,
    # instead of you re-describing the requirement in prose each round
  • Use the interview pattern for unfamiliar domains (cache invalidation, failure modes).

    For a domain you don't fully know, ask Claude to interview YOU before coding. Its questions surface considerations you hadn't specified — invalidation timing, failure handling — so they're designed in rather than discovered in production.

    جو موضوع آپ پوری طرح نہیں جانتے، اس میں کوڈنگ سے پہلے Claude سے اپنا انٹرویو لینے کو کہیں۔ اس کے سوال ایسی باتیں سامنے لاتے ہیں جو آپ نے نہیں بتائیں — invalidation کا وقت، ناکامی سنبھالنا — تاکہ وہ پہلے سے ڈیزائن میں آ جائیں، production میں دریافت نہ ہوں۔

    You: "Before coding the cache, interview me."
    Claude: "1) invalidation trigger?  2) TTL?  3) behavior when the backend
             is down?  4) is stale-while-revalidate acceptable?"
    // surfaces edge cases you hadn't specified, BEFORE any code exists
  • Provide specific example input/expected output to fix edge cases (null values in migrations).

    Target a stubborn edge case by showing the exact input and the output you expect for it (e.g. a null legacy field → the default you want). The concrete pair removes the ambiguity that generic instructions leave.

    کسی ضدی خاص صورت کو نشانہ بنانے کے لیے عین ان پٹ اور اس کے لیے متوقع آؤٹ پٹ دکھائیں (مثلاً null پرانا خانہ ← آپ کی مطلوبہ ڈیفالٹ)۔ یہ ٹھوس جوڑا وہ الجھن ختم کر دیتا ہے جو عام ہدایات چھوڑ دیتی ہیں۔

    "Legacy rows have a null signup_source. Expected:
       in: { signup_source: null }  ->  out: { signup_source: 'unknown' }"
    // the concrete pair removes ambiguity generic instructions leave

Edge Cases & Traps

  • Batch interacting fixes into one detailed message so the model reasons about their interaction; independent issues can go one at a time.
3.6

Integrate Claude Code into CI/CD pipelines

Knowledge of

  • -p / --print runs non-interactively (prevents input hangs) and exits after output.

    In CI there's no human to answer prompts. -p (aka --print) processes the prompt, writes the result to stdout, and exits — so the job never hangs waiting for input.

    CI میں پرامپٹ کا جواب دینے والا کوئی انسان نہیں۔ -p (یعنی --print) پرامپٹ چلاتا ہے، نتیجہ stdout پر لکھتا ہے، اور بند ہو جاتا ہے — تاکہ job کبھی ان پٹ کے انتظار میں نہ اٹکے۔

    claude -p "Analyze this pull request for security issues"
    Exam tip: CI job hangs waiting for input ⇒ add -p/--print. CLAUDE_HEADLESS and --batch are NOT real flags.
  • --output-format json + --json-schema enforce structured, machine-parseable output.

    For posting findings as inline PR comments, you need parseable output. --output-format json with a --json-schema gives you a predictable shape your pipeline can consume.

    نتائج کو inline PR کمنٹس کے طور پر لگانے کے لیے آپ کو پڑھنے لائق آؤٹ پٹ چاہیے۔ --output-format json اور --json-schema ایک متوقع شکل دیتے ہیں جسے آپ کی pipeline استعمال کر سکے۔

    claude -p "Review changes" --output-format json --json-schema ./review.schema.json
  • CLAUDE.md supplies project context (testing standards, fixtures, review criteria) to CI-invoked Claude.

    The same CLAUDE.md that guides interactive use also grounds CI runs — documenting fixtures and review criteria raises quality and cuts low-value output.

    جو CLAUDE.md لائیو استعمال کی رہنمائی کرتی ہے وہی CI چکروں کو بھی بنیاد دیتی ہے — fixtures اور جائزے کے اصول لکھنا معیار بڑھاتا اور کم قیمتی آؤٹ پٹ گھٹاتا ہے۔

  • Session isolation: the session that GENERATED code is less effective at reviewing its own changes than an independent instance.

    A model that just wrote the code carries its own reasoning and is less likely to question it. A fresh, independent instance catches subtle issues the author-instance rationalizes away.

    جس ماڈل نے ابھی کوڈ لکھا وہ اپنی سوچ ساتھ رکھتا ہے اور اس پر شک کم کرتا ہے۔ ایک تازہ، الگ instance وہ باریک مسائل پکڑتا ہے جنہیں لکھنے والا instance صفائیاں دے کر ٹال دیتا ہے۔

    Exam tip: Review quality: prefer an INDEPENDENT review instance over self-review by the generating session.

Skills in

  • Run with -p to avoid interactive hangs.

    CI has no human to answer prompts. -p/--print processes the prompt, writes output to stdout, and exits — so the job completes instead of blocking forever on input. (CLAUDE_HEADLESS and --batch aren't real flags.)

    CI میں پرامپٹ کا جواب دینے والا انسان نہیں۔ -p/--print پرامپٹ چلاتا ہے، آؤٹ پٹ stdout پر لکھتا ہے، اور بند ہو جاتا ہے — تاکہ job ان پٹ پر ہمیشہ اٹکنے کے بجائے مکمل ہو۔ (CLAUDE_HEADLESS اور --batch اصلی flags نہیں۔)

    claude -p "Analyze this pull request for security issues"
  • --output-format json + --json-schema for structured findings posted as inline PR comments.

    To turn review output into inline PR comments your pipeline must parse it reliably. Requesting JSON against a fixed schema guarantees a predictable shape instead of free-form prose you'd have to scrape.

    جائزے کے آؤٹ پٹ کو inline PR کمنٹس بنانے کے لیے آپ کی pipeline کو اسے بھروسے سے پڑھنا ہوگا۔ ایک طے شدہ schema کے مطابق JSON مانگنا ایک متوقع شکل یقینی بناتا ہے، بجائے آزاد عبارت کے جسے کھرچنا پڑے۔

    claude -p "Review changes" --output-format json --json-schema ./review.schema.json
  • Include prior review findings when re-running after new commits; report only new/unaddressed issues to avoid duplicate comments.

    On each re-run, feed in what was already reported and instruct Claude to surface only new or still-open issues — otherwise it re-posts the same comments.

    ہر بار دوبارہ چلانے پر جو پہلے رپورٹ ہو چکا وہ ساتھ دیں اور Claude کو کہیں کہ صرف نئے یا ابھی کھلے مسئلے دکھائے — ورنہ وہ وہی کمنٹس دوبارہ لگا دے گا۔

    claude -p "Review the new commits. ALREADY REPORTED (do not repeat):
      - L42 SQL injection
      - L88 missing null check
    Report ONLY new or still-unaddressed issues."
    // otherwise it re-posts the same comments on every push
  • Provide existing test files so generation doesn't duplicate covered scenarios.

    Show the test-generation run what's already covered so it fills gaps instead of re-writing tests that exist. Without that context it duplicates scenarios and produces low-value noise.

    ٹیسٹ بنانے والے چکر کو دکھائیں کیا پہلے سے ڈھکا ہوا ہے تاکہ وہ موجود ٹیسٹ دوبارہ لکھنے کے بجائے خالی جگہیں بھرے۔ اس سیاق کے بغیر وہ صورتیں دہراتا اور کم قیمتی شور پیدا کرتا ہے۔

    claude -p "Add tests for payments.py. EXISTING coverage:
      test_payments.py already covers refunds + the happy path.
    Fill gaps only (declined cards, partial refunds)."
    // without this it duplicates covered scenarios = low-value noise
  • Document testing standards/fixtures in CLAUDE.md to raise test-gen quality and reduce low-value output.

    The CLAUDE.md that grounds interactive work also grounds CI runs. Documenting fixtures, naming conventions, and review criteria means generated tests match house style and the reviewer flags what the team actually cares about.

    جو CLAUDE.md لائیو کام کو بنیاد دیتی ہے وہی CI چکروں کو بھی۔ fixtures، ناموں کے اصول، اور جائزے کے معیار لکھنے سے بنائے گئے ٹیسٹ گھر کے انداز سے ملتے ہیں اور جائزہ لینے والا وہی نشان زد کرتا ہے جس کی ٹیم کو واقعی پرواہ ہے۔

    # CLAUDE.md
    ## Testing
    - use pytest + the `db_session` fixture (never a real DB)
    - name tests test_<unit>_<condition>_<expected>
    // CI test-gen now matches house style instead of inventing its own

Edge Cases & Traps

  • CLAUDE_HEADLESS=true and --batch are NOT real flags — distractors. Redirecting stdin from /dev/null is a Unix workaround, not the documented fix; use -p.

🧠 Knowledge Check · 31 questions

Score: 0/31

1.You want a /review slash command available to every developer automatically on clone/pull. Where does it belong?

2.Test files are spread throughout the codebase and must all follow the same conventions regardless of location. What's the most maintainable mechanism?

3.A task requires restructuring a monolith into microservices across dozens of files with several viable designs. Which approach fits?

4.A new teammate isn't receiving a coding instruction that works for you. What's the likely cause?

5.Your CI job running claude "Analyze this PR" hangs waiting for input. What's the correct fix?

6.Why use context: fork in a skill's SKILL.md frontmatter?

7.A teammate isn't getting an instruction that others have. What is the most likely cause?

8.Which keeps a large CLAUDE.md modular?

9.What is the .claude/rules/ directory used for?

10.Which command shows which memory files are currently loaded?

11.You want a slash command available to every developer on clone/pull. Where does it go?

12.A skill produces verbose codebase-analysis output you don't want polluting the main chat. Which frontmatter setting helps?

13.Which skill frontmatter field restricts what the skill can do (e.g., limit it to file writes)?

14.When should you use a skill rather than CLAUDE.md?

15.A convention must apply to all test files spread across many directories. What is the best mechanism?

16.What is the benefit of path-scoped rules that load only on matching files?

17.You have Terraform conventions. How do you scope a rule so it loads only when editing Terraform?

18.Which task best fits plan mode?

19.Which is a good use of the Explore subagent?

20.Direct execution (not plan mode) is appropriate for…

21.Descriptions are being interpreted inconsistently. What improves reliability most?

22.In iterative refinement, what does the interview pattern mean?

23.You have several interacting problems plus some independent ones. What is the best approach?

24.A Claude Code CI job hangs waiting for input. What fixes it?

25.How do you get machine-parseable structured findings from Claude Code in CI?

26.For reviewing generated code in CI, which is more reliable?

27.A convention must apply to every test file, but they're scattered across many feature folders. Best mechanism?

28.A slash command should be available to every developer the moment they clone the repo. Where does it belong?

29.You want a codebase-analysis skill's verbose output to stay OUT of the main conversation. What frontmatter helps?

30.The task is to migrate 45 files across service boundaries with several viable approaches. Which mode fits?

31.In CI, a Claude Code job hangs forever waiting on input. What's the documented fix?