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
26 changes: 1 addition & 25 deletions .claude/command-templates/close-issue.md
Original file line number Diff line number Diff line change
@@ -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 <NUMBER> with {{ ISSUE_NUMBER }} in branch names
- Replace <description> 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?
{{ INJECT:knowledge/procedures/close-issue-procedure.md }}
103 changes: 103 additions & 0 deletions .github/scripts/aggregate-knowledge.sh
Original file line number Diff line number Diff line change
@@ -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
Comment thread
atxtechbro marked this conversation as resolved.

# 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
Comment thread
atxtechbro marked this conversation as resolved.
}

# 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/"
8 changes: 8 additions & 0 deletions .github/workflow-prompts/issue-triage.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-trigger-claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
});
68 changes: 64 additions & 4 deletions .github/workflows/claude-implementation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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<<EOF" >> $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: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Description: Untrusted input has been detected in GitHub Actions workflow run commands. This creates a significant security risk for script injection attacks, where malicious actors could exploit workflow inputs to execute unauthorized commands. GitHub Actions workflows should validate and sanitize all user-provided inputs, especially those used in run commands. Consider using GitHub's built-in security features like actions/github-script for safer command execution, or implement proper input validation before using dynamic values in run commands.

Learn more

Similar issue at line numbers 93, 94, 95, 96, 97, 98, 99, 100, 101, and 128.

Severity: High

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The remediation replaces the vulnerable run commands with uses: actions/github-script@v7 steps. This change eliminates the risk of script injection by executing JavaScript code within a controlled environment provided by the GitHub Actions script action.

Suggested change
run: |
- name: Aggregate knowledge base
id: knowledge
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
function aggregateKnowledge() {
console.log("Aggregating knowledge base for Claude...");
const knowledgeBasePath = path.join('.github', 'scripts', 'aggregate-knowledge.sh');
if (fs.existsSync(knowledgeBasePath)) {
const knowledge = fs.readFileSync(knowledgeBasePath, 'utf8');
console.log(`Knowledge base size: ${knowledge.length} characters`);
return knowledge;
} else {
console.log("Knowledge base script not found.");
return "";
}
}
const knowledge = aggregateKnowledge();
core.setOutput('content', knowledge);
- name: Prepare implementation prompt
id: prepare-prompt
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
function preparePrompt() {
const isIssue = !!context.payload.issue && !context.payload.issue.pull_request;
let prompt = '';
if (isIssue) {
console.log("Preparing prompt for issue implementation...");
const issueNumber = context.payload.issue.number;
const issueTitle = context.payload.issue.title;
const issueBody = context.payload.issue.body;
const templatePath = path.join('.github', 'workflow-prompts', 'issue-implementation.md');
if (fs.existsSync(templatePath)) {
let template = fs.readFileSync(templatePath, 'utf8');
prompt = template
.replace('{{ KNOWLEDGE_BASE }}', '${{ steps.knowledge.outputs.content }}')
.replace('{{ ISSUE_NUMBER }}', issueNumber)
.replace('{{ ISSUE_TITLE }}', issueTitle)
.replace('{{ ISSUE_BODY }}', issueBody)
.replace('{{ REPO }}', context.repo.owner + '/' + context.repo.repo);
} else {
console.log("Issue implementation template not found.");
prompt = "Error: Template not found.";
}
} else {
console.log("Preparing prompt for PR review...");
prompt = `${{ steps.knowledge.outputs.content }}
## PR Review Request
The user has requested: ${context.payload.comment.body}
Please review and respond to this pull request comment with the full context of the codebase principles and procedures available above.`;
}
return prompt;
}
const prompt = preparePrompt();
core.setOutput('prompt', prompt);
- uses: anthropics/claude-code-base-action@beta
with:

# 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<<EOF" >> $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"
allowed_tools: "Bash(*),LS,Read,Write,Edit,MultiEdit,Glob,Grep,Task,TodoWrite,WebFetch(domain:*),WebSearch,mcp__git,mcp__github"
timeout_minutes: "30"
47 changes: 44 additions & 3 deletions knowledge/procedures/close-issue-procedure.md
Original file line number Diff line number Diff line change
@@ -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)
{{ KNOWLEDGE_BASE }}
<!-- Note: If you see "{{ KNOWLEDGE_BASE }}" above as literal text, you're running locally and knowledge is already preloaded -->

## Core Principle: Target-First Development
{{ INJECT:principles/tracer-bullets.md }}

## Analyze Issue #{{ ISSUE_NUMBER }}
<!-- This procedure IS the implementation - executable documentation -->
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 <NUMBER> with {{ ISSUE_NUMBER }} in branch names
- Replace <description> 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?