Skip to content

feat(dev-workflow): enable code-review agent to load project context and skills - #201

Merged
NTCoding merged 8 commits into
mainfrom
issue-200-enable-claude-code-review-agen
Jan 18, 2026
Merged

NTCoding merged 8 commits into
mainfrom
issue-200-enable-claude-code-review-agen

Conversation

@NTCoding

@NTCoding NTCoding commented Jan 18, 2026 •

Copy link
Copy Markdown
Owner

References

User request to improve code review quality

Summary

The code-review agent in complete-task workflow runs without project context or skills. This limits its ability to apply project-specific conventions like separation-of-concerns from the claude-skillz plugin.

Full Details

Two changes needed: (1) Update tools/dev-workflow/complete-task/steps/code-review.ts to pass flags that enable Claude to load project context and skills. (2) Update .claude/agents/code-review.md to instruct the agent to use the separation-of-concerns skill for code organization analysis.

Acceptance Criteria

  • code-review.ts passes appropriate flags for project context/skills
  • code-review.md references separation-of-concerns skill
  • Code review agent can apply project-specific conventions

Amendment

feat(dev-workflow): enable Claude code-review agent to load project context and skills

Summary by CodeRabbit

  • New Features

    • Code review workflow now runs an automated separation-of-concerns assessment.
    • Code review queries can include project-level settings.
  • Improvements

    • Tooling detects SDK-launched agents and short-circuits hook processing to avoid unnecessary work.
    • Code review findings schema now accepts null/absent line numbers for more robust validation.

✏️ Tip: You can customize this high-level summary in your review settings.

…and skills

- Add settingSources option to claude.ts to allow loading project settings
- Pass settingSources: ['project'] in code-review.ts to enable skills/plugins
- Add CLAUDE_SDK_AGENT env var to skip dev-workflow hooks for SDK agents
- Update code-review.md to load and apply separation-of-concerns skill
- Fix schema to accept null line numbers in findings

Closes #200

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 18, 2026 •

Copy link
Copy Markdown

Deploying living-architecture with  Cloudflare Pages  Cloudflare Pages

Latest commit: c6fdf05
Status: ✅  Deploy successful!
Preview URL: https://9ecb623c.living-architecture.pages.dev
Branch Preview URL: https://issue-200-enable-claude-code.living-architecture.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jan 18, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@NTCoding has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4434017 and c6fdf05.

📒 Files selected for processing (4)
  • tools/dev-workflow/complete-task/steps/code-review.ts
  • tools/dev-workflow/dev-workflow-hooks/claude-code-input-schemas.ts
  • tools/dev-workflow/external-clients/claude.ts
  • tools/dev-workflow/workflow-runner/schemas.ts

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a project-level settingSources option to Claude queries, inserts a separation-of-concerns skill step into the code-review guidance, detects and short-circuits SDK-spawned agents in dev-workflow hooks, and allows null values for finding.line in workflow schemas.

Changes

Cohort / File(s) Summary
Agent guidance & step
\.claude/agents/code-review.md, tools/dev-workflow/complete-task/steps/code-review.ts
Adds instruction to apply a separation-of-concerns skill in code-review guidance; passes settingSources: ['project'] into the Claude query.
SDK agent detection / hook flow
tools/dev-workflow/dev-workflow-hooks/dev-workflow-hooks.ts
Adds CLAUDE_SDK_AGENT-based detection (isRunningAsSDKSpawnedAgent()), skipHooksForSDKAgents() and an early return in main() to bypass stdin processing for SDK-spawned agents.
Claude client settings
tools/dev-workflow/external-clients/claude.ts
Exports CLAUDE_SDK_AGENT_ENV_VAR; adds `type SettingSource = 'user'
Schema adjustment
tools/dev-workflow/workflow-runner/schemas.ts
Changes findingSchema.line from .optional() to .nullish() to allow explicit null as well as missing/undefined.

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment
    participant Hooks as dev-workflow-hooks
    participant STDIN as STDIN
    participant Parser as JSON Parser/Validator
    participant Handler as Handler (router)
    participant Claude as Claude SDK

    Env->>Hooks: process starts (env vars set)
    Hooks->>Hooks: isRunningAsSDKSpawnedAgent()?
    alt SDK-spawned agent (CLAUDE_SDK_AGENT=true)
        Hooks->>Hooks: skipHooksForSDKAgents() and return
    else Normal run
        STDIN->>Hooks: input stream
        Hooks->>Parser: parse + validate JSON
        Parser->>Handler: route to appropriate handler
        Handler->>Claude: claude.query(..., settingSources:['project'])
        Claude-->>Handler: response
        Handler-->>Hooks: output JSON
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels

Review effort 2/5

Poem

🐇 I hop through code with nimble paws,

I split concerns and mind the laws,
Project flags set, the agents steer,
Hooks skip when SDKs appear,
Schemas welcome null — a tidy cheer.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request—enabling the code-review agent to load project context and skills.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 Security concerns

Sensitive information exposure:
env: { ...process.env, CLAUDE_SDK_AGENT: 'true' } propagates the entire parent process environment into the spawned SDK agent. If the agent process or any logs/crash reports can be accessed, this may leak secrets present in environment variables (tokens, API keys, CI credentials). Consider passing an allowlist of required env vars instead of spreading all of process.env.

⚡ Recommended focus areas for review

Breaking Change

ClaudeQueryOptions now requires settingSources, which will break any existing claude.query(...) call sites that weren’t updated in this PR. Ensure all callers pass an appropriate value (and consider a safe default) so the change doesn’t introduce runtime/compile failures in other workflow steps.

type SettingSource = 'user' | 'project' | 'local'

interface ClaudeQueryOptions<T> {
  prompt: string
  model: 'opus' | 'sonnet' | 'haiku'
  outputSchema: z.ZodSchema<T>
  outputPath: string
  /**
   * Control which filesystem settings to load.
   * - 'user' - Global user settings (~/.claude/settings.json)
   * - 'project' - Project settings (.claude/settings.json) and CLAUDE.md
   * - 'local' - Local settings (.claude/settings.local.json)
   *
   * Required to load project context, skills, and plugins.
   */
  settingSources: SettingSource[]
}
Hook Behavior

SDK-spawned agents now bypass hooks and print an empty JSON object. Confirm this matches the hook protocol expected by the workflow runner (e.g., required fields, stdout vs stderr expectations) and that skipping hooks won’t silently disable important safeguards for agent-triggered operations.

function isRunningAsSDKSpawnedAgent(): boolean {
  return process.env.CLAUDE_SDK_AGENT === 'true'
}

function skipHooksForSDKAgents(): void {
  console.log(JSON.stringify({}))
}

async function main(): Promise<void> {
  if (isRunningAsSDKSpawnedAgent()) {
    skipHooksForSDKAgents()
    return
  }
Schema Compatibility

findingSchema.line changed from optional to nullable/undefined (nullish). Validate downstream consumers handle null (not just undefined) and that any JSON serialization/validation expectations remain consistent across the workflow.

const findingSchema = z.object({
  severity: z.enum(['critical', 'major', 'minor']),
  file: z.string(),
  line: z.number().nullish(),
  message: z.string(),
})

Comment thread tools/dev-workflow/external-clients/claude.ts
Comment thread tools/dev-workflow/external-clients/claude.ts
Comment thread tools/dev-workflow/dev-workflow-hooks/dev-workflow-hooks.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tools/dev-workflow/dev-workflow-hooks/dev-workflow-hooks.ts`:
- Around line 66-69: Extract the magic environment variable string into a shared
constant (e.g., export const CLAUDE_SDK_AGENT_ENV_VAR = 'CLAUDE_SDK_AGENT') in a
common module and import it where needed; replace direct uses of the literal
with the constant in the isRunningAsSDKSpawnedAgent implementation and in any
callers like the dev-workflow-hooks file that call isRunningAsSDKSpawnedAgent()
or skipHooksForSDKAgents(), and update claude.ts to export the constant so both
modules reference the same identifier to avoid typos and ease future changes.

Comment thread tools/dev-workflow/dev-workflow-hooks/dev-workflow-hooks.ts
NTCoding and others added 2 commits January 18, 2026 11:19
- Make settingSources optional in ClaudeQueryOptions interface with @default [] JSDoc
- Improve isRunningAsSDKSpawnedAgent to handle different truthy values (1, true case-insensitive)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ntation

- Export CLAUDE_SDK_AGENT_ENV_VAR constant from claude.ts for reuse
- Import and use constant in dev-workflow-hooks.ts to prevent typos
- Add comprehensive JSDoc explaining why env var approach is necessary
- Uses bracket notation for computed property key in env object

Co-Authored-By: Claude Opus 4.5 <[email protected]>
NTCoding and others added 5 commits January 18, 2026 11:30
- Remove reference to non-existent skill from code-review.md
- Move schemas to code-review.ts where they are used
- Delete now-unused workflow-runner/schemas.ts
- Rename functions for domain clarity

Fixes organization violation: schemas were grouped by type rather than
usage. Now they live alongside code that uses them.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update code-review.md to reference software-design-principles skill (available skill)
- Replace dangerous ?? fallback with fail-fast error in parseJsonFromCodeBlockOrRaw
- Add documentation explaining schemas organization in dev-workflow-hooks
- Extract getReviewerNames function to separate agent name resolution from execution

Follows fail-fast principle: clear errors instead of silent fallbacks.
Improves separation of concerns: agent coordination logic separated.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove skill reference from code-review.md agent instructions
- Rename parseJsonFromCodeBlockOrRaw to parseJsonFromCodeBlock
  (clarifies function only extracts from code blocks, fails otherwise)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove code comment from CLAUDE_SDK_AGENT_ENV_VAR (no-comments policy)
- Add validation for reviewer agent names (fail-fast principle)
- Add JSDoc documentation for SettingSource type

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Make ReviewerResult internal-only since it's not used outside code-review.ts

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant