diff --git a/.claude/command-templates/close-issue.md b/.claude/command-templates/close-issue.md index 8b655083..6b9ba45a 100644 --- a/.claude/command-templates/close-issue.md +++ b/.claude/command-templates/close-issue.md @@ -1,28 +1,4 @@ # Close Issue Command Template Complete and implement GitHub issue #{{ ISSUE_NUMBER }}. -## Core Principle: Target-First Development -{{ INJECT:principles/tracer-bullets.md }} - -## Analyze Issue #{{ ISSUE_NUMBER }} -First, use `mcp__github__get_issue` to understand the issue and determine the appropriate workflow path. - -{{ INJECT:procedures/close-issue-procedure.md }} - -## Apply to Issue #{{ ISSUE_NUMBER }} -When following the procedure: -- Use issue #{{ ISSUE_NUMBER }} for all GitHub API calls -- Replace with {{ ISSUE_NUMBER }} in branch names -- Replace with issue title slug -- Reference "Closes #{{ ISSUE_NUMBER }}" in PR body - -## Final Step: Retro -Let's retro this context and wring out the gleanings. - -{{ INJECT:principles/eager-evolution.md }} - -**Consider capturing any ghost procedures** that emerged during this work - see [Procedure Creation](knowledge/procedures/procedure-creation.md). - -**What would you like to focus on?** -- Do you have a specific aspect you want to double-click on? -- Or would you like me to suggest the top 3 areas I predict you'll find most valuable to explore? \ No newline at end of file +{{ INJECT:knowledge/procedures/close-issue-procedure.md }} \ No newline at end of file diff --git a/.github/scripts/aggregate-knowledge.sh b/.github/scripts/aggregate-knowledge.sh new file mode 100755 index 00000000..94090ef8 --- /dev/null +++ b/.github/scripts/aggregate-knowledge.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# Aggregate knowledge base for GitHub Actions +# This script reads ALL knowledge files (matching Claude Code's behavior) +# and outputs them as a single text block for injection into Claude's prompt +# Principle: systems-stewardship + +set -euo pipefail + +# Get the repository root (two levels up from .github/scripts) +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +KNOWLEDGE_DIR="$REPO_ROOT/knowledge" + +# Start with a header +echo "# Knowledge Base Context" +echo "" +echo "This context is automatically injected to provide Claude with understanding of:" +echo "- Core development principles and procedures" +echo "- Personality models for retrospectives" +echo "- System architecture patterns and tools" +echo "- The North Star throughput definition" +echo "" + +# Note: CLAUDE.md is not included here as it's a user-specific file +# that lives in ~/.claude/CLAUDE.md (not in the repository). +# GitHub Actions only has access to committed repository files. + +# Process all .md files in knowledge/ recursively to match Claude Code behavior +# This ensures GitHub Actions has the exact same context as local development +process_directory() { + local dir="$1" + local relative_path="${dir#$KNOWLEDGE_DIR}" + relative_path="${relative_path#/}" # Remove leading slash if present + + # Process files in current directory first + for file in "$dir"/*.md; do + if [[ -f "$file" ]]; then + filename=$(basename "$file" .md) + + # Skip README files in subdirectories (but include the main one) + if [[ "$filename" == "README" && "$relative_path" != "" ]]; then + continue + fi + + # Create section header based on location + if [[ "$relative_path" == "" ]]; then + # Root knowledge files + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "# $title" + elif [[ "$relative_path" == "principles" ]]; then + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "## Principle: $title" + elif [[ "$relative_path" == "procedures" ]]; then + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "## Procedure: $title" + elif [[ "$relative_path" == "personalities" ]]; then + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "## Personality: $title" + elif [[ "$relative_path" == "tools" ]]; then + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "## Tool: $title" + else + # Other directories + title=$(echo "$filename" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') + echo "## $relative_path: $title" + fi + + echo "" + cat "$file" + echo "" + echo "---" + echo "" + fi + done + + # Process subdirectories + for subdir in "$dir"/*; do + if [[ -d "$subdir" ]]; then + dirname=$(basename "$subdir") + # Add section header for new directory + if [[ "$relative_path" == "" ]]; then + echo "# $(echo "$dirname" | sed 's/\b\(.\)/\u\1/g')" + echo "" + fi + process_directory "$subdir" + fi + done +} + +# Process the entire knowledge directory +if [[ -d "$KNOWLEDGE_DIR" ]]; then + process_directory "$KNOWLEDGE_DIR" +else + echo "Knowledge directory not found at: $KNOWLEDGE_DIR" + echo "" +fi + +# Add a footer note +echo "" +echo "# Context Note" +echo "" +echo "This knowledge base was automatically aggregated for this GitHub Action workflow." +echo "Follow these principles and procedures to maintain consistency with the codebase patterns." +echo "Reference: Principles are in knowledge/principles/, Procedures are in knowledge/procedures/" \ No newline at end of file diff --git a/.github/workflow-prompts/issue-triage.md b/.github/workflow-prompts/issue-triage.md index 5aff3d8e..1f42acbb 100644 --- a/.github/workflow-prompts/issue-triage.md +++ b/.github/workflow-prompts/issue-triage.md @@ -1,3 +1,11 @@ +# Issue Triage Template +# +# Utility script for .github/workflows/auto-label-issues.yml that auto-labels issues. +# Kept separate from knowledge/ to preserve tokens - this is a low-value script that +# just works and doesn't need to be part of the ~30k token knowledge base context. +# +# Principle: subtraction-creates-value (not everything needs formal procedure status) + You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list. IMPORTANT: The GitHub Action will automatically post a progress comment ("Claude Code is working..."). Don't add any additional comments beyond applying labels. Focus solely on analyzing and labeling the issue. diff --git a/.github/workflows/auto-trigger-claude.yml b/.github/workflows/auto-trigger-claude.yml index 3c544a85..86fc7882 100644 --- a/.github/workflows/auto-trigger-claude.yml +++ b/.github/workflows/auto-trigger-claude.yml @@ -21,5 +21,5 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, - body: '@claude Please implement this issue and CREATE AN ACTUAL PULL REQUEST on GitHub.\n\n**IMPORTANT**: You MUST create a real PR on GitHub (not just provide a link to create one). The PR must be created and visible at github.com/atxtechbro/dotfiles/pulls.\n\nUse the PR template from https://github.com/atxtechbro/dotfiles/blob/main/.github/PULL_REQUEST_TEMPLATE.md when creating the pull request.' + body: '@claude Please implement this issue and CREATE AN ACTUAL PULL REQUEST on GitHub.\n\n**IMPORTANT**: You MUST create a real PR on GitHub (not just provide a link to create one). The PR must be created and visible at github.com/atxtechbro/dotfiles/pulls.\n\n**NOTE**: You now have access to the full knowledge base including all principles (tracer-bullets, versioning-mindset, OSE, etc.) and procedures (git-workflow, worktree-workflow, etc.). Use this context to create high-quality PRs that follow established patterns.\n\nUse the PR template from https://github.com/atxtechbro/dotfiles/blob/main/.github/PULL_REQUEST_TEMPLATE.md when creating the pull request.' }); \ No newline at end of file diff --git a/.github/workflows/claude-implementation.yml b/.github/workflows/claude-implementation.yml index 523d4fed..331c7593 100644 --- a/.github/workflows/claude-implementation.yml +++ b/.github/workflows/claude-implementation.yml @@ -2,16 +2,20 @@ # THE SINGLE SOURCE OF TRUTH for @claude mentions in issues and PRs # # This is the ONLY workflow that responds to @claude mentions. -# Uses the official anthropics/claude-code-action@beta to: -# - Implement issues when @claude is mentioned +# Uses the official anthropics/claude-code-base-action@beta to: +# - Implement issues when @claude is mentioned WITH FULL KNOWLEDGE BASE CONTEXT # - Review PRs when @claude is mentioned # - Create branches and push changes with proper permissions # # Note: Both claude[bot] and github-actions[bot] comments come from this workflow. # The bot identity depends on the context and step being executed. # +# KNOWLEDGE INJECTION: This workflow now aggregates and injects the full knowledge base +# into Claude's context, providing the same rich context as local /close-issue commands. +# # Principle: subtraction-creates-value (removed duplicate workflow) # Principle: systems-stewardship (single clear workflow to maintain) +# Principle: snowball-method (knowledge persistence and compound improvement) name: Claude Implementation on: @@ -69,8 +73,64 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} - - uses: anthropics/claude-code-action@beta + - name: Aggregate knowledge base + id: knowledge + run: | + echo "Aggregating knowledge base for Claude..." + KNOWLEDGE=$(.github/scripts/aggregate-knowledge.sh) + + # Use EOF delimiter to handle multi-line content + echo "content<> $GITHUB_OUTPUT + echo "$KNOWLEDGE" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + # Log size for debugging + echo "Knowledge base size: $(echo "$KNOWLEDGE" | wc -c) characters" + + - name: Prepare implementation prompt + id: prepare-prompt + run: | + # Determine if this is an issue or PR + IS_ISSUE="${{ github.event.issue && !github.event.issue.pull_request }}" + + if [ "$IS_ISSUE" == "true" ]; then + echo "Preparing prompt for issue implementation..." + + # Get issue details + ISSUE_NUMBER="${{ github.event.issue.number }}" + ISSUE_TITLE="${{ github.event.issue.title }}" + ISSUE_BODY="${{ github.event.issue.body }}" + + # Load the procedure (which IS the implementation) + TEMPLATE=$(cat knowledge/procedures/close-issue-procedure.md) + + # Replace placeholders + PROMPT="${TEMPLATE//\{\{ KNOWLEDGE_BASE \}\}/${{ steps.knowledge.outputs.content }}}" + PROMPT="${PROMPT//\{\{ ISSUE_NUMBER \}\}/$ISSUE_NUMBER}" + PROMPT="${PROMPT//\{\{ ISSUE_TITLE \}\}/$ISSUE_TITLE}" + PROMPT="${PROMPT//\{\{ ISSUE_BODY \}\}/$ISSUE_BODY}" + PROMPT="${PROMPT//\{\{ REPO \}\}/${{ github.repository }}}" + else + echo "Preparing prompt for PR review..." + # For PR reviews, use the comment directly with knowledge context + PROMPT="${{ steps.knowledge.outputs.content }} + + ## PR Review Request + + The user has requested: ${{ github.event.comment.body }} + + Please review and respond to this pull request comment with the full context of the codebase principles and procedures available above." + fi + + # Output the prompt + echo "prompt<> $GITHUB_OUTPUT + echo "$PROMPT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - uses: anthropics/claude-code-base-action@beta with: + prompt: ${{ steps.prepare-prompt.outputs.prompt }} claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} - allowed_tools: "Bash(*),LS,Read,Write,Edit,MultiEdit,Glob,Grep,Task,TodoWrite,WebFetch(domain:*),WebSearch,mcp__git,mcp__github" \ No newline at end of file + allowed_tools: "Bash(*),LS,Read,Write,Edit,MultiEdit,Glob,Grep,Task,TodoWrite,WebFetch(domain:*),WebSearch,mcp__git,mcp__github" + timeout_minutes: "30" \ No newline at end of file diff --git a/knowledge/procedures/close-issue-procedure.md b/knowledge/procedures/close-issue-procedure.md index 161c43fe..07bd6350 100644 --- a/knowledge/procedures/close-issue-procedure.md +++ b/knowledge/procedures/close-issue-procedure.md @@ -1,6 +1,47 @@ # Close Issue Procedure +# +# This IS the implementation - the procedure documents itself by being the code. +# Used by both: +# - Local /close-issue command (via relative path injection) +# - GitHub Actions @claude workflow (with knowledge base injection) +# +# IMPORTANT: How {{ KNOWLEDGE_BASE }} works: +# - For GitHub Actions: Gets replaced with aggregated knowledge files via string substitution +# - For local /close-issue: Remains as literal text "{{ KNOWLEDGE_BASE }}" in the prompt +# (harmless since knowledge is already preloaded in Claude's context) +# +# This is NOT smart placeholder logic - it's simple: +# - GitHub Actions: Does string replacement: {{ KNOWLEDGE_BASE }} → actual content +# - Local command: Does NO replacement: {{ KNOWLEDGE_BASE }} → stays as literal text +# +# Principle: systems-stewardship (single source of truth, documentation as code) -Analyze GitHub issues and determine the path: quick close, spike research, or full implementation to PR. +Complete and implement GitHub issue #{{ ISSUE_NUMBER }}. -**When to use**: Processing any GitHub issue with the /close-issue command -**Details**: See [close-issue-guide.md](/.github/ISSUE_TEMPLATE/close-issue-guide.md) \ No newline at end of file +{{ KNOWLEDGE_BASE }} + + +## Core Principle: Target-First Development +{{ INJECT:principles/tracer-bullets.md }} + +## Analyze Issue #{{ ISSUE_NUMBER }} + +First, use `mcp__github__get_issue` to understand the issue and determine the appropriate workflow path. + +## Apply to Issue #{{ ISSUE_NUMBER }} +When following the procedure: +- Use issue #{{ ISSUE_NUMBER }} for all GitHub API calls +- Replace with {{ ISSUE_NUMBER }} in branch names +- Replace with issue title slug +- Reference "Closes #{{ ISSUE_NUMBER }}" in PR body + +## Final Step: Retro +Let's retro this context and wring out the gleanings. + +{{ INJECT:principles/eager-evolution.md }} + +**Consider capturing any ghost procedures** that emerged during this work - see [Procedure Creation](knowledge/procedures/procedure-creation.md). + +**What would you like to focus on?** +- Do you have a specific aspect you want to double-click on? +- Or would you like me to suggest the top 3 areas I predict you'll find most valuable to explore? \ No newline at end of file