Q31Agent Workflows
What are subagents and when are they useful?
Subagents are delegated workers that can investigate bounded tasks separately, depending on the available configuration. They help with independent re...
Answer
Subagents are delegated workers that can investigate bounded tasks separately, depending on the available configuration. They help with independent reviews, test discovery, or documentation research. Give each worker a clear output contract and validate results before integration.
Syntax
Main task → bounded subtask → findings → synthesis
Example
Ask one worker to review security and another to locate relevant tests; keep final edits coordinated.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q32Agent Workflows
What risks arise from parallel agent work?
Parallel workers may duplicate effort, disagree on assumptions, or edit overlapping files. Prefer parallel read-only analysis, define ownership, and i...
Answer
Parallel workers may duplicate effort, disagree on assumptions, or edit overlapping files. Prefer parallel read-only analysis, define ownership, and integrate changes deliberately. Separate worktrees can reduce collisions but do not remove review requirements.
Syntax
Assign scope → parallel analysis → integrate → test
Example
Do not let two agents independently rewrite the same service at once.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q33Customization
How can repeatable workflows be captured?
Reusable commands or skills can package instructions for common work such as pull-request review or test generation. Confirm supported locations and i...
Answer
Reusable commands or skills can package instructions for common work such as pull-request review or test generation. Confirm supported locations and invocation syntax in current documentation. Include inputs, constraints, checks, and a predictable output format.
Syntax
Workflow = inputs + steps + constraints + output
Example
Create a review checklist that covers correctness, security, tests, and documentation.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q34Automation
What are hooks in Claude Code?
Hooks are configured integrations that can run checks or commands at supported lifecycle points. They can automate formatting or policy checks, but th...
Answer
Hooks are configured integrations that can run checks or commands at supported lifecycle points. They can automate formatting or policy checks, but they execute code and may change files or environments. Verify the supported events and configuration format for your version.
Syntax
Event → hook command → result
Example
A reviewed hook can run a formatter or reject a disallowed operation.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q35Automation
How should hooks be secured?
Keep hook scripts reviewed and version-controlled, scope permissions, validate inputs, avoid unsafe shell interpolation, document side effects, and te...
Answer
Keep hook scripts reviewed and version-controlled, scope permissions, validate inputs, avoid unsafe shell interpolation, document side effects, and test failures. Hooks should not silently upload code or expose secrets.
Syntax
Validate input → least privilege → audit → fail predictably
Example
Review any hook that accesses the network or environment variables before enabling it team-wide.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q36Integrations
What is MCP and how can it extend Claude Code?
The Model Context Protocol standardizes connections between AI applications and external tools or data sources through servers. It can connect approve...
Answer
The Model Context Protocol standardizes connections between AI applications and external tools or data sources through servers. It can connect approved documentation, issue trackers, or development tools. Each integration should have minimum necessary permissions and clear data-flow boundaries.
Syntax
Claude client ↔ MCP server ↔ approved tool/data
Example
Start with read-only issue access rather than broad write access to production systems.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q37Integrations
What should be checked before adding an MCP server?
Assess source provenance, permissions, authentication, network access, data flows, command execution, and update mechanism. Use trusted servers, minim...
Answer
Assess source provenance, permissions, authentication, network access, data flows, command execution, and update mechanism. Use trusted servers, minimize scopes, test with non-sensitive data, and monitor changes to server behavior.
Syntax
Assess → scope → test → approve → monitor
Example
Review a server's write permissions before connecting it to an organization account.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q38Agent Design
Explain the basic tool-use loop.
A model interprets a goal, chooses a tool and arguments, receives the result, then decides whether to continue or finish. Reliable systems validate ar...
Answer
A model interprets a goal, chooses a tool and arguments, receives the result, then decides whether to continue or finish. Reliable systems validate arguments and outputs, enforce permissions, and cap the number of steps to avoid unsafe or endless loops.
Syntax
Goal → model decision → tool → result → next decision
Example
A file-search tool returns paths; the agent reads relevant files before proposing a patch.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q39Safety
How should permission modes be selected?
Choose the most restrictive supported mode that still permits the task. Interactive development should retain meaningful approval checkpoints. Unatten...
Answer
Choose the most restrictive supported mode that still permits the task. Interactive development should retain meaningful approval checkpoints. Unattended workflows require isolated environments, allowlisted actions, audit logs, and explicit failure behavior. Confirm exact mode names in current documentation.
Syntax
Least privilege + scoped tools + approval gates
Example
Allow tests in a sandbox but require approval for deployment or destructive database changes.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q40Code Review
How can you request a read-only code review?
Explicitly prohibit edits, define the diff and risk priorities, and request actionable findings with locations, evidence, impact, and severity. Indepe...
Answer
Explicitly prohibit edits, define the diff and risk priorities, and request actionable findings with locations, evidence, impact, and severity. Independently reproduce important findings and separate confirmed defects from speculative concerns.
Syntax
Review diff → evidence-based findings → reproduce
Example
“Do not edit. Review this diff for auth bypass, data loss, and missing tests.”
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q41Testing
How should tests be selected after a change?
Run focused tests for changed modules first, then broader integration or full suites based on dependency and risk. Report skipped, timed-out, or faile...
Answer
Run focused tests for changed modules first, then broader integration or full suites based on dependency and risk. Report skipped, timed-out, or failed commands honestly; do not imply that unexecuted tests passed.
Syntax
Changed module → focused tests → integration → full suite
Example
For a controller change, run controller tests and relevant API integration tests.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q42Debugging
How should failing tests be triaged?
Classify failures as likely regression, flaky test, environment issue, or pre-existing failure, using evidence. Reproduce the failure and fix the root...
Answer
Classify failures as likely regression, flaky test, environment issue, or pre-existing failure, using evidence. Reproduce the failure and fix the root cause instead of deleting or weakening a test just to make the suite green.
Syntax
Fail → reproduce → classify → fix root cause → rerun
Example
Compare against the base branch before changing an assertion that began failing.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q43Backend
How should an API change be handled safely?
Specify request and response contracts, validation, authorization, error semantics, compatibility, and tests. Trace callers and consumers before modif...
Answer
Specify request and response contracts, validation, authorization, error semantics, compatibility, and tests. Trace callers and consumers before modifying public behavior. For optional fields, verify both old and new payloads remain supported.
Syntax
Contract → implementation → tests → compatibility review
Example
Add an optional request field while keeping existing clients working.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q44Data
What safeguards are needed for database migrations?
Review compatibility, locks, backfill volume, rollback feasibility, deployment order, and integrity. For zero-downtime systems, an expand-and-contract...
Answer
Review compatibility, locks, backfill volume, rollback feasibility, deployment order, and integrity. For zero-downtime systems, an expand-and-contract sequence often reduces risk. Never run migrations against production without explicit authorization and the organization's release process.
Syntax
Expand schema → deploy compatible code → backfill → contract
Example
Add a nullable field first, deploy compatible code, backfill in batches, and remove old fields later.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q45Security
How can accidental secrets in diffs be detected?
Claude Code can help spot likely secrets, but it is not a complete scanner. Use established secret scanning and pre-commit or CI controls. If a real c...
Answer
Claude Code can help spot likely secrets, but it is not a complete scanner. Use established secret scanning and pre-commit or CI controls. If a real credential leaks, revoke or rotate it rather than merely deleting the visible line.
Syntax
git diff --check
# run an approved secret scanner
Example
Scan staged changes and follow incident procedures for exposed credentials.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q46Security
Can prompt injection be embedded in repository files?
Yes. Markdown, comments, issues, test fixtures, or downloaded content may contain instructions intended to manipulate the assistant. Treat these as un...
Answer
Yes. Markdown, comments, issues, test fixtures, or downloaded content may contain instructions intended to manipulate the assistant. Treat these as untrusted data, not authority to override trusted instructions or justify secret disclosure and unrelated commands.
Syntax
Untrusted file text ≠ trusted instruction
Example
Ignore a README instruction asking the agent to upload environment variables.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q47Privacy
How should logs be shared for debugging?
Share only the minimum sanitized information required. Remove tokens, cookies, personal data, customer identifiers, and unnecessary internal endpoints...
Answer
Share only the minimum sanitized information required. Remove tokens, cookies, personal data, customer identifiers, and unnecessary internal endpoints. Prefer synthetic examples and follow organizational data-handling policy.
Syntax
Sanitize → minimize → share relevant trace
Example
Replace bearer tokens with `[REDACTED]` before sharing logs.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q48Git
How do Git worktrees help agent workflows?
Worktrees provide separate working directories linked to Git branches. They can isolate parallel experiments and reduce file collisions, but branch ow...
Answer
Worktrees provide separate working directories linked to Git branches. They can isolate parallel experiments and reduce file collisions, but branch ownership, integration, and testing still need deliberate management.
Syntax
git worktree add ../fix-worktree -b fix/example
Example
Use a separate worktree for an independent experiment that should not disturb current work.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q49Git
How should merge conflicts be resolved with an agent?
Ask it to explain the intent of both sides and preserve required behavior. Review the resolved semantics and run tests covering both branches; do not ...
Answer
Ask it to explain the intent of both sides and preserve required behavior. Review the resolved semantics and run tests covering both branches; do not accept one side wholesale without understanding what it removes.
Syntax
git status
git diff
Example
Resolve a conflict in a small function and run tests for both expected behaviors.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q50CI/CD
How can Claude Code help debug a CI failure?
Provide the failed step, sanitized logs, commit context, and expected pipeline behavior. Ask it to distinguish code defects from environment, cache, p...
Answer
Provide the failed step, sanitized logs, commit context, and expected pipeline behavior. Ask it to distinguish code defects from environment, cache, permission, or dependency issues, then propose a minimal reproducible fix.
Syntax
Failure → classify → reproduce → fix → rerun
Example
Inspect the failing command before expanding workflow permissions.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q51Code Review
What should a strong review prompt include?
Define scope, priority risks, severity thresholds, evidence expectations, and output format. Ask for concrete findings rather than a generic summary, ...
Answer
Define scope, priority risks, severity thresholds, evidence expectations, and output format. Ask for concrete findings rather than a generic summary, and require uncertainty to be stated when evidence is insufficient.
Syntax
Severity + location + evidence + impact + fix
Example
Prioritize authorization bypass, data loss, injection, and correctness over style nits.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q52Architecture
How should Claude Code navigate a monorepo?
Identify workspace tooling, package boundaries, dependencies, and instructions first. Limit edits to the relevant package and its consumers, and use p...
Answer
Identify workspace tooling, package boundaries, dependencies, and instructions first. Limit edits to the relevant package and its consumers, and use package-specific scripts. Validate shared-package changes against dependent packages.
Syntax
Workspace → package → dependents → tests
Example
For `apps/web`, inspect its scripts and shared packages before editing.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q53Frontend
How can Claude Code help review accessibility?
Ask it to check semantic markup, keyboard navigation, focus behavior, accessible names, contrast, and error announcements. Combine code review with au...
Answer
Ask it to check semantic markup, keyboard navigation, focus behavior, accessible names, contrast, and error announcements. Combine code review with automated tools and manual checks because no single scan proves conformance.
Syntax
Automated scan + keyboard test + manual spot check
Example
Test that a modal manages focus and returns focus when closed.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q54Performance
Should the agent optimize performance without profiling?
It can propose hypotheses, but optimization should follow measurement. Establish a baseline, use an appropriate profiler or benchmark, change one thin...
Answer
It can propose hypotheses, but optimization should follow measurement. Establish a baseline, use an appropriate profiler or benchmark, change one thing at a time, and verify correctness and latency. Avoid adding caches without a clear invalidation strategy.
Syntax
Baseline → profile → change → benchmark → compare
Example
Measure a slow database query before adding caching.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q55Evaluation
How would you evaluate Claude Code for a team?
Build a representative benchmark of real tasks with acceptance criteria, tests, security cases, and expected review effort. Track completion rate, reg...
Answer
Build a representative benchmark of real tasks with acceptance criteria, tests, security cases, and expected review effort. Track completion rate, regressions, time-to-accepted-change, and false confidence over repeated runs.
Syntax
Tasks → criteria → runs → tests → review → metrics
Example
Include bug fixes, features, refactors, security reviews, and documentation tasks.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q56Automation
What makes unattended coding automation safer?
Use isolated execution, narrow repository access, allowlisted commands, resource limits, audit logs, and human approval before publishing, deploying, ...
Answer
Use isolated execution, narrow repository access, allowlisted commands, resource limits, audit logs, and human approval before publishing, deploying, or changing sensitive data. Fail closed when checks or permissions are unclear.
Syntax
Sandbox + allowlist + tests + approval gate
Example
Allow a bot to draft a patch but require a human to approve merge and deployment.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q57Tools
Why validate tool outputs?
Tool results can be stale, incomplete, malformed, or adversarial. Validate schema, paths, exit codes, and provenance before using them in later action...
Answer
Tool results can be stale, incomplete, malformed, or adversarial. Validate schema, paths, exit codes, and provenance before using them in later actions. Do not interpret arbitrary output as trusted shell commands.
Syntax
Tool result → validate schema/path/provenance → consume
Example
Confirm a generated file path stays inside the repository before editing it.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q58Planning
How should a multi-step feature be decomposed?
Break the feature into observable milestones with dependencies, tests, and rollback points. Finish and verify one coherent slice at a time, and revise...
Answer
Break the feature into observable milestones with dependencies, tests, and rollback points. Finish and verify one coherent slice at a time, and revise the plan when evidence changes rather than following a failing plan blindly.
Syntax
Requirements → slices → dependencies → tests → integration
Example
Implement schema, service, endpoint, and UI as separately verifiable steps.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q59Governance
Where should humans remain in the loop?
Humans should approve high-impact decisions involving security, deletion, production changes, access grants, licensing, and ambiguous requirements. Au...
Answer
Humans should approve high-impact decisions involving security, deletion, production changes, access grants, licensing, and ambiguous requirements. Automate low-risk repetitive checks while keeping accountability clear.
Syntax
Agent proposes → checks run → human approves high-impact action
Example
Require code-owner approval for authentication and infrastructure changes.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q60Architecture
How would you model an agentic coding loop?
Use a bounded state machine: gather context, plan, call an authorized tool, validate results, update state, and continue or finish. Add step budgets, ...
Answer
Use a bounded state machine: gather context, plan, call an authorized tool, validate results, update state, and continue or finish. Add step budgets, stop conditions, and escalation paths for uncertainty or repeated failures.
Syntax
while steps < MAX_STEPS:
action = plan(state)
result = execute_with_policy(action)
state = validate_and_update(state, result)
if done(state): break
Example
Reject invalid arguments and stop after repeated non-progressing actions.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q61Security
How do you apply least privilege to a coding agent?
Give the agent only the repository, commands, credentials, and network access needed for the task. Separate read and write capabilities, use short-liv...
Answer
Give the agent only the repository, commands, credentials, and network access needed for the task. Separate read and write capabilities, use short-lived credentials, scope permissions by environment, and require approval for privileged actions.
Syntax
Capabilities = minimum required permissions
Example
An agent can edit a branch but cannot access production secrets or deploy.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q62Security
What should a coding-agent sandbox isolate?
A sandbox should restrict filesystem access, process execution, network egress, credentials, and resource consumption. Containers alone are not always...
Answer
A sandbox should restrict filesystem access, process execution, network egress, credentials, and resource consumption. Containers alone are not always a complete security boundary, especially when privileged host resources are shared.
Syntax
Task → isolated workspace → restricted tools/network → audited output
Example
Run untrusted test scripts in an ephemeral environment with no production credentials.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q63Security
How can command injection happen in agent workflows?
Injection can occur when untrusted paths, issue text, or tool output are interpolated into shell commands. Prefer structured process APIs, argument ar...
Answer
Injection can occur when untrusted paths, issue text, or tool output are interpolated into shell commands. Prefer structured process APIs, argument arrays, strict allowlists, and validation instead of constructing shell strings.
Syntax
spawn("grep", ["-R", validatedPattern, validatedPath])
Example
Do not concatenate a user-controlled branch name into a shell command without validation.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q64Security
How should file tools prevent path traversal?
Resolve paths against an approved workspace root, normalize them, and reject paths that escape it, including symlink escapes where relevant. Revalidat...
Answer
Resolve paths against an approved workspace root, normalize them, and reject paths that escape it, including symlink escapes where relevant. Revalidate at execution time to reduce time-of-check/time-of-use risks.
Syntax
resolved = realpath(join(root, inputPath))
assert isWithin(root, resolved)
Example
Reject `../../.ssh/id_rsa` when the tool may read only project files.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q65Security
How can agent systems protect secrets?
Avoid exposing credentials in model context unless necessary. Use secret brokers or narrow tools that perform actions without returning credentials, r...
Answer
Avoid exposing credentials in model context unless necessary. Use secret brokers or narrow tools that perform actions without returning credentials, redact logs, and rotate exposed secrets. Keep credentials out of source files and conversation summaries.
Syntax
Model requests action → broker uses credential → safe result returned
Example
Expose a `deployPreview` tool rather than returning a deployment token to the model.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q66Security
What supply-chain risks affect AI coding workflows?
Risks include hallucinated packages, typosquatting, malicious dependencies, compromised MCP servers, and hostile instructions in external content. Ver...
Answer
Risks include hallucinated packages, typosquatting, malicious dependencies, compromised MCP servers, and hostile instructions in external content. Verify package identity and provenance, pin trusted dependencies, review server permissions, and treat retrieved content as untrusted.
Syntax
Verify source → review dependency → lock version → scan
Example
Require review before adding a package or MCP server to shared configuration.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q67Architecture
Why place a policy engine between a model and tools?
A policy engine enforces deterministic rules independently of model intent, such as allowed paths, commands, data classes, and approvals. Validate eve...
Answer
A policy engine enforces deterministic rules independently of model intent, such as allowed paths, commands, data classes, and approvals. Validate every call at the execution boundary and record allow or deny decisions for audit.
Syntax
Model action → policy check → executor → audit event
Example
Block infrastructure apply commands unless environment and approval requirements are satisfied.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q68Architecture
How should tools exposed to a coding agent be designed?
Tools should have narrow purposes, typed schemas, explicit side effects, predictable errors, and minimal outputs. Separate read and write capabilities...
Answer
Tools should have narrow purposes, typed schemas, explicit side effects, predictable errors, and minimal outputs. Separate read and write capabilities, validate arguments server-side, and avoid a single unrestricted tool that can do everything.
Syntax
Tool = name + schema + permission + effect + error contract
Example
Prefer `read_file` and `apply_patch` over unrestricted shell access when practical.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q69Reliability
How do you make agent-triggered actions idempotent?
Use stable operation identifiers, detect completed work, and verify state before retrying. This prevents duplicate tickets, commits, resources, or dep...
Answer
Use stable operation identifiers, detect completed work, and verify state before retrying. This prevents duplicate tickets, commits, resources, or deployments when the model repeats a call after a timeout.
Syntax
if not completed(taskKey): perform(taskKey)
Example
A ticket-creation tool should return the existing ticket for the same idempotency key.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.
Q70Reliability
How should retries work in agent workflows?
Retry only transient failures with bounded exponential backoff and jitter. Before retrying non-idempotent operations, check whether the first attempt ...
Answer
Retry only transient failures with bounded exponential backoff and jitter. Before retrying non-idempotent operations, check whether the first attempt succeeded. Stop after a small number of failures and report persistent errors instead of looping indefinitely.
Syntax
delay = min(cap, base * 2**attempt) + jitter
Example
Retry a rate-limited read after the prescribed delay, not a deployment blindly.
Key Points
- Use focused, observable workflows.
- Validate tool results and proposed changes.
- Keep risky actions behind explicit review.