Skip to content

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 21, 2026

Adds a new prompt_runtime frontmatter setting for DeepWork rules:

  • send_to_stopping_agent (default): Returns prompt to the triggering agent
  • claude: Invokes Claude Code in headless mode to process the rule

This enables rules to be processed by a dedicated Claude instance instead of being returned to the agent that triggered the hook, useful for:

  • Cross-platform rule processing (e.g., when Gemini triggers a rule)
  • Autonomous rule handling without blocking the main agent
  • Consistent rule processing regardless of triggering agent

Changes:

  • Add prompt_runtime field to rules schema
  • Add PromptRuntime enum and parsing logic to rules_parser.py
  • Implement Claude headless invocation in rules_check.py
  • Update all existing rules with prompt_runtime: send_to_stopping_agent
  • Update documentation with examples and field reference

claude and others added 11 commits January 21, 2026 00:48
Adds a new `prompt_runtime` frontmatter setting for DeepWork rules:
- `send_to_stopping_agent` (default): Returns prompt to the triggering agent
- `claude`: Invokes Claude Code in headless mode to process the rule

This enables rules to be processed by a dedicated Claude instance instead
of being returned to the agent that triggered the hook, useful for:
- Cross-platform rule processing (e.g., when Gemini triggers a rule)
- Autonomous rule handling without blocking the main agent
- Consistent rule processing regardless of triggering agent

Changes:
- Add prompt_runtime field to rules schema
- Add PromptRuntime enum and parsing logic to rules_parser.py
- Implement Claude headless invocation in rules_check.py
- Update all existing rules with prompt_runtime: send_to_stopping_agent
- Update documentation with examples and field reference
… Claude prompt

Tests:
- Add TestPromptRuntime class for PromptRuntime enum behavior
- Add TestLoadPromptRuntimeFromFile class for parsing from rule files
- Add TestFormatClaudePrompt class for Claude prompt formatting
- Add TestParseClaudeResponse class for parsing Claude's structured output
- Add tests for transcript_path parameter in format_claude_prompt

Implementation:
- Update format_claude_prompt to accept optional transcript_path parameter
- Include conversation context section in Claude prompt when transcript provided
- Pass hook_input.transcript_path to format_claude_prompt in hook
These rules now invoke Claude Code in headless mode to autonomously
check and update documentation when source code changes, rather than
returning prompts to the triggering agent.
Creates test_claude_runtime/ directory with a simple Python file that
triggers the new prompt_runtime: claude feature. When edited, the rule
invokes Claude Code in headless mode to review the code changes.

Updates manual tests README with test documentation.
- Bump version to 0.5.0
- Add CHANGELOG entry for prompt_runtime setting
- Document prompt_runtime in README and architecture docs
- Add pytest and gitpython as dev dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The prompt_runtime setting only applies to prompt actions, not command
actions. Removed it from:
- manual-test-command-action.md
- manual-test-infinite-block-command.md
- uv-lock-sync.md

The parser still accepts prompt_runtime on command rules (for backwards
compatibility) but ignores it since command rules don't use prompts.
When CLAUDE_CODE_REMOTE=true, the claude command cannot be executed.
Instead of hanging, the system now returns the prompt to the agent with
instructions to evaluate it manually via a sub-agent.

Changes:
- Add is_claude_code_remote() function to detect remote environment
- Update invoke_claude_headless() to return fallback prompt when remote
- Add "Rules Requiring Sub-Agent Evaluation" section in hook output
- Add tests for the new fallback behavior
Updated instructions to explain that testers should introduce a blatant
error (e.g., division by zero) to verify Claude detects and blocks it.
Also noted the fallback behavior in Claude Code Web environments.
Tests cover:
- Successful allow/block decisions
- Non-zero exit code handling
- Subprocess timeout handling
- Generic exception handling
- Correct command-line arguments
Claude Code now has separate Stop and SubagentStop events. Previously,
Stop would trigger for both the main agent and subagents. This change
ensures that when a Stop hook is defined, it is also registered for
SubagentStop so the same validation logic triggers for both events.

Changes:
- generator.py: Duplicate Stop hooks to SubagentStop in skill templates
- hooks_syncer.py: Duplicate Stop hooks to SubagentStop in global hooks
- Add tests verifying SubagentStop hook registration
@nhorton nhorton changed the base branch from main to claude/add-subagent-stop-hook-ho4cv January 21, 2026 02:57
Base automatically changed from claude/add-subagent-stop-hook-ho4cv to main January 21, 2026 21:31
nhorton and others added 6 commits January 22, 2026 11:33
Resolves merge conflicts in:
- manual_tests/README.md
- tests/shell_script_tests/test_rules_stop_hook.py
- tests/unit/test_stop_hooks.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolves conflict in src/deepwork/hooks/rules_check.py by incorporating
both changes:
- Promised rules handling (from main): updates FAILED queue entries to
  SKIPPED when they have a promise tag
- Prompt runtime separation (from this branch): separates prompt results
  by runtime type for Claude vs agent processing
Consolidated all changes from 0.4.0-0.5.2 into a single 0.4.0 release:

Added:
- Doc specs feature for document quality criteria
- prompt_runtime setting for rules (send_to_stopping_agent vs claude)
- Claude headless mode execution for automated rule remediation
- deepwork rules clear_queue CLI command
- Code review stage in commit job
- Session start hook for version checking
- Manual tests job

Changed:
- BREAKING: Renamed document_type to doc_spec
- Step.outputs now uses OutputSpec dataclass
- Updated deepwork_jobs to v0.6.0

Fixed:
- Infinite loop bug in rules system with promise tags
- COMMAND rules promise handling queue status
- Quality criteria validation logic
- compare_to: prompt mode file detection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@nhorton nhorton force-pushed the claude/add-prompt-runtime-setting-gPJDA branch from 4b9f026 to dcea5e4 Compare January 22, 2026 22:02
Documents the findings from debugging why `prompt_runtime: claude`
hangs when running inside Claude Code. Key findings:
- Direct bash execution works, Python subprocess doesn't
- The hang appears to be at the process management level
- Nested Claude invocation seems intentionally limited
- Feature should work from external automation (CI, cron)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants