Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 18 additions & 39 deletions .deepwork/jobs/commit/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,23 @@ steps:
outputs:
- code_reviewed # implicit state: code has been reviewed and issues addressed
dependencies: []
hooks:
after_agent:
- prompt: |
Verify the code review is complete:
1. Changed files were identified
2. Sub-agent reviewed the code for general issues, DRY opportunities, naming clarity, and test coverage
3. All identified issues were addressed or documented as intentional
If ALL criteria are met, include `<promise>✓ Quality Criteria Met</promise>`.
quality_criteria:
- "Changed files were identified"
- "Sub-agent reviewed the code for general issues, DRY opportunities, naming clarity, and test coverage"
- "All identified issues were addressed or documented as intentional"

- id: test
name: "Run Tests"
description: "Pulls latest code and runs tests until all pass. Use after code review passes to verify changes work correctly."
instructions_file: steps/test.md
inputs:
- name: test_command
description: "Test command to run (optional - will auto-detect if not provided)"
inputs: []
outputs:
- tests_passing # implicit state: all tests pass
dependencies:
- review
hooks:
after_agent:
- prompt: |
Verify the tests are passing:
1. Latest code was pulled from the branch
2. All tests completed successfully
3. No test failures or errors remain
4. Test output shows passing status
If ALL criteria are met, include `<promise>✓ Quality Criteria Met</promise>`.
quality_criteria:
- "Latest code was pulled from the branch"
- "All tests are passing"

- id: lint
name: "Lint Code"
Expand All @@ -88,14 +76,10 @@ steps:
- code_formatted # implicit state: code formatted and linted
dependencies:
- test
hooks:
after_agent:
- prompt: |
Verify the linting is complete:
1. ruff format was run successfully
2. ruff check was run successfully (with --fix)
3. No remaining lint errors
If ALL criteria are met, include `<promise>✓ Quality Criteria Met</promise>`.
quality_criteria:
- "ruff format was run successfully"
- "ruff check was run with --fix flag"
- "No remaining lint errors"

- id: commit_and_push
name: "Commit and Push"
Expand All @@ -106,14 +90,9 @@ steps:
- changes_committed # implicit state: changes committed and pushed
dependencies:
- lint
hooks:
after_agent:
- prompt: |
Verify the commit is ready:
1. Changed files list was reviewed by the agent
2. Files match what was modified during this session (or unexpected changes were investigated)
3. CHANGELOG.md was updated with entries in the [Unreleased] section (if changes warrant documentation)
4. Version numbers were NOT modified (pyproject.toml version and CHANGELOG version headers must remain unchanged)
5. Commit was created with appropriate message
6. Changes were pushed to remote
If ALL criteria are met, include `<promise>✓ Quality Criteria Met</promise>`.
quality_criteria:
- "Changed files were verified against expectations"
- "CHANGELOG.md was updated with entries in [Unreleased] section (if changes warrant documentation)"
- "Version numbers were NOT modified (pyproject.toml version and CHANGELOG version headers unchanged)"
- "Commit was created with appropriate message"
- "Changes were pushed to remote"
11 changes: 4 additions & 7 deletions .deepwork/jobs/commit/steps/commit_and_push.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,11 @@ Check the list of changed files against what was modified during this session, e

## Quality Criteria

- Changed files list was reviewed by the agent
- Files match what was modified during this session (or unexpected changes were investigated and handled)
- CHANGELOG.md was updated with entries in the `[Unreleased]` section (if changes warrant documentation)
- Version numbers were NOT modified (in pyproject.toml or CHANGELOG.md version headers)
- Commit message follows project conventions
- Commit was created successfully
- Changed files were verified against expectations
- CHANGELOG.md was updated with entries in [Unreleased] section (if changes warrant documentation)
- Version numbers were NOT modified (pyproject.toml version and CHANGELOG version headers unchanged)
- Commit was created with appropriate message
- Changes were pushed to remote
- When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response

## Context

Expand Down
4 changes: 1 addition & 3 deletions .deepwork/jobs/commit/steps/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ Report the results of each command.

- ruff format was run successfully
- ruff check was run with --fix flag
- No remaining lint errors (or all are documented and intentional)
- Sub-agent was used to conserve context
- When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response
- No remaining lint errors

## Context

Expand Down
62 changes: 6 additions & 56 deletions .deepwork/jobs/commit/steps/review.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,11 @@ Use a sub-agent to review the staged/changed code and identify issues that shoul

Use the Task tool with these parameters:
- `subagent_type`: "general-purpose"
- `prompt`: Include the list of changed files and the review criteria below

The sub-agent should review each changed file for:

**General Issues**
- Logic errors or potential bugs
- Error handling gaps
- Security concerns
- Performance issues

**DRY Opportunities**
- Duplicated code that should be extracted into functions
- Repeated patterns that could be abstracted
- Copy-pasted logic with minor variations

**Naming Clarity**
- Variables, functions, and classes should have clear, descriptive names
- Names should reflect purpose and intent
- Avoid abbreviations that aren't universally understood
- Consistent naming conventions throughout

**Test Coverage**
- New functions or classes should have corresponding tests
- New code paths should be tested
- Edge cases should be covered
- If tests are missing, note what should be tested
- `prompt`: Instruct the sub-agent to:
- Read the code review standards from `doc/code_review_standards.md`
- Read each of the changed files
- Review each file against the standards
- Report issues found with file, line number, severity, and suggested fix

3. **Review sub-agent findings**
- Examine each issue identified
Expand All @@ -65,40 +44,11 @@ Use a sub-agent to review the staged/changed code and identify issues that shoul
- If you made substantial changes, consider running another review pass
- Ensure fixes didn't introduce new issues

## Example Sub-Agent Prompt

```
Review the following changed files for code quality issues:

Files to review:
- src/module.py
- src/utils.py
- tests/test_module.py

For each file, check for:

1. **General issues**: Logic errors, bugs, error handling gaps, security concerns
2. **DRY opportunities**: Duplicated code, repeated patterns that should be extracted
3. **Naming clarity**: Are variable/function/class names clear and descriptive?
4. **Test coverage**: Does new functionality have corresponding tests?

Read each file and provide a structured report of issues found, organized by category.
For each issue, include:
- File and line number
- Description of the issue
- Suggested fix

If no issues are found in a category, state that explicitly.
```

## Quality Criteria

- Changed files were identified
- Sub-agent reviewed all changed files
- Issues were categorized (general, DRY, naming, tests)
- Sub-agent read the code review standards and reviewed all changed files
- All identified issues were addressed or documented as intentional
- Sub-agent was used to conserve context
- When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response

## Context

Expand Down
4 changes: 1 addition & 3 deletions .deepwork/jobs/commit/steps/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ Execute the test suite for the project and iteratively fix any failures until al
## Quality Criteria

- Latest code was pulled from the branch
- Test command was correctly identified or used from input
- All tests are now passing
- When all criteria are met, include `<promise>✓ Quality Criteria Met</promise>` in your response
- All tests are passing

## Context

Expand Down
67 changes: 67 additions & 0 deletions doc/code_review_standards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Code Review Standards

This document defines the standards used during code review in the commit workflow.

## Review Categories

### General Issues

Check for:
- Logic errors or potential bugs
- Error handling gaps
- Security concerns (injection, authentication, authorization)
- Performance issues (inefficient algorithms, unnecessary computation)
- Resource leaks (unclosed files, connections)

### DRY (Don't Repeat Yourself)

Look for:
- Duplicated code that should be extracted into functions
- Repeated patterns that could be abstracted
- Copy-pasted logic with minor variations
- Similar code blocks that differ only in variable names

### Naming Clarity

Ensure:
- Variables, functions, and classes have clear, descriptive names
- Names reflect purpose and intent
- Abbreviations are avoided unless universally understood
- Naming conventions are consistent throughout the codebase

### Test Coverage

Verify:
- New functions or classes have corresponding tests
- New code paths are tested
- Edge cases are covered
- Error conditions are tested
- If tests are missing, note what should be tested

### Test Quality

Ensure tests add value and are not duplicative:
- Each test should verify a distinct behavior or scenario
- Tests should not duplicate what other tests already cover
- Test names should clearly describe what they're testing
- Tests should be meaningful, not just checking trivial cases
- Avoid testing implementation details; focus on behavior
- If multiple tests appear redundant, suggest consolidation

## Severity Levels

When reporting issues, categorize by severity:

- **Critical**: Must fix before commit (bugs, security issues)
- **High**: Should fix before commit (logic errors, missing error handling)
- **Medium**: Recommended to fix (DRY violations, unclear naming)
- **Low**: Nice to have (style improvements, minor optimizations)

## Review Output Format

For each issue found, provide:
1. File and line number
2. Severity level
3. Category (General/DRY/Naming/Tests)
4. Description of the issue
5. Suggested fix or improvement
5 changes: 5 additions & 0 deletions library/jobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ The job definition file contains:
- `version`: Semantic version (e.g., "1.0.0")
- `summary`: Brief description (under 200 characters)
- `description`: Detailed explanation of the job's purpose
- `workflows`: Named sequences of steps (optional)
- `name`: Workflow identifier
- `summary`: What the workflow accomplishes
- `steps`: Ordered list of step IDs to execute
- `steps`: Array of step definitions with:
- `id`: Step identifier
- `name`: Human-readable step name
Expand All @@ -45,6 +49,7 @@ The job definition file contains:
- `inputs`: What the step requires
- `outputs`: What the step produces
- `dependencies`: Other steps that must complete first
- `quality_criteria`: Measurable criteria for step completion

### steps/

Expand Down
74 changes: 74 additions & 0 deletions library/jobs/commit/block_bash_with_instructions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# block_bash_with_instructions.sh - Blocks specific bash commands and provides alternative instructions
#
# This hook intercepts Bash tool use calls and blocks commands that match
# specific patterns, providing alternative instructions to the agent.
#
# Usage: Registered as a PreToolUse hook in .claude/settings.json
#
# Input (stdin): JSON from Claude Code hook system containing tool_name and tool_input
# Output (stderr): Error message if blocked (Claude Code reads stderr for exit code 2)
# Exit codes:
# 0 - Success (allow action)
# 2 - Blocking error (prevent action with message)

set -e

# =============================================================================
# BLOCKED COMMANDS CONFIGURATION
# =============================================================================
# Format: Each entry is a regex pattern followed by a delimiter (|||) and instructions
# The regex is matched against the full bash command
# Add new blocked commands here:

BLOCKED_COMMANDS=(
'^[[:space:]]*git[[:space:]]+commit|||All commits must be done via the `/commit` skill. Do not use git commit directly. Instead, run `/commit` to start the commit workflow which includes code review, testing, and linting before committing.'
)

# =============================================================================
# HOOK LOGIC - DO NOT MODIFY BELOW UNLESS NECESSARY
# =============================================================================

# Read stdin into variable
HOOK_INPUT=""
if [ ! -t 0 ]; then
HOOK_INPUT=$(cat)
fi

# Exit early if no input
if [ -z "${HOOK_INPUT}" ]; then
exit 0
fi

# Extract tool_name from input
TOOL_NAME=$(echo "${HOOK_INPUT}" | jq -r '.tool_name // empty' 2>/dev/null)

# Only process Bash tool calls
if [ "${TOOL_NAME}" != "Bash" ]; then
exit 0
fi

# Extract the command from tool_input
COMMAND=$(echo "${HOOK_INPUT}" | jq -r '.tool_input.command // empty' 2>/dev/null)

# Exit if no command
if [ -z "${COMMAND}" ]; then
exit 0
fi

# Check each blocked pattern
for entry in "${BLOCKED_COMMANDS[@]}"; do
# Split entry by delimiter
pattern="${entry%%|||*}"
instructions="${entry##*|||}"

# Check if command matches pattern (using extended regex)
if echo "${COMMAND}" | grep -qE "${pattern}"; then
# Output error message to stderr (Claude Code reads stderr for exit code 2)
echo "${instructions}" >&2
exit 2
fi
done

# Command is allowed
exit 0
Loading