mirror of
https://github.com/anthropics/claude-code.git
synced 2026-02-19 04:27:33 -08:00
Compare commits
98 Commits
boris/uiyw
...
bcherny-pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aaffa4e6d | ||
|
|
f5b24d5480 | ||
|
|
07e6bec5ff | ||
|
|
cf8c6fdf2d | ||
|
|
d720bf7aba | ||
|
|
dde41f6225 | ||
|
|
78e0785950 | ||
|
|
b3658880e5 | ||
|
|
9be8e07e92 | ||
|
|
c904f0f409 | ||
|
|
6418cacb0b | ||
|
|
4fd2c49e8b | ||
|
|
48ed55b459 | ||
|
|
8b2cbe3f86 | ||
|
|
40251280cc | ||
|
|
8f0379c698 | ||
|
|
10c1ec5391 | ||
|
|
6c7836e02f | ||
|
|
6f6fc43c73 | ||
|
|
944eb4eff6 | ||
|
|
21df74bb49 | ||
|
|
66ce673883 | ||
|
|
07b198b9de | ||
|
|
8ad36c459c | ||
|
|
b48dfb8e87 | ||
|
|
55219b8b4e | ||
|
|
812c27b8b3 | ||
|
|
e0d79c3571 | ||
|
|
c8207b4f68 | ||
|
|
4c056f7a09 | ||
|
|
b328530abd | ||
|
|
486b305708 | ||
|
|
8e23e7d791 | ||
|
|
68d43db2a0 | ||
|
|
9285dfbf2f | ||
|
|
90c26533d1 | ||
|
|
d45bce242d | ||
|
|
f91aed5440 | ||
|
|
54a4ed0f5e | ||
|
|
33e37bd828 | ||
|
|
ff15c6f147 | ||
|
|
0cbe1dcac5 | ||
|
|
a705bca81c | ||
|
|
ecaf0d818a | ||
|
|
397442ddf5 | ||
|
|
5def9264e5 | ||
|
|
0149827a77 | ||
|
|
c93c724eeb | ||
|
|
545d78c331 | ||
|
|
e16c9857ef | ||
|
|
a39ae004aa | ||
|
|
74ba615503 | ||
|
|
3d2166eec9 | ||
|
|
beacb95320 | ||
|
|
80ddbcd96d | ||
|
|
390f11039c | ||
|
|
5f9dcdb410 | ||
|
|
a8e927ee24 | ||
|
|
21cf5c2293 | ||
|
|
46ca39c463 | ||
|
|
d6503abfd9 | ||
|
|
94bcec8740 | ||
|
|
a6091b65c0 | ||
|
|
b6f507833d | ||
|
|
e39df663ca | ||
|
|
820644f291 | ||
|
|
78f98bb6b3 | ||
|
|
c11fc4619b | ||
|
|
885a36faf3 | ||
|
|
eb0b297e11 | ||
|
|
6370398030 | ||
|
|
bb083eea94 | ||
|
|
d9cc2b58a2 | ||
|
|
0c3b9e94e1 | ||
|
|
3cf808d1ec | ||
|
|
e9f7c53b7c | ||
|
|
d1510f5eef | ||
|
|
715ea8ed4a | ||
|
|
0b881fcb4d | ||
|
|
9ca3c81936 | ||
|
|
4f162e6b79 | ||
|
|
e05a423901 | ||
|
|
4c9bd9cd74 | ||
|
|
0d22403ad1 | ||
|
|
931543f95f | ||
|
|
437f92b52e | ||
|
|
14c8c0df32 | ||
|
|
6767546666 | ||
|
|
5e54b4ccc1 | ||
|
|
895ce94465 | ||
|
|
7d0c29fe1a | ||
|
|
51fecc9881 | ||
|
|
8fdc766a16 | ||
|
|
26e9a5d6d3 | ||
|
|
e394b39220 | ||
|
|
d337047b92 | ||
|
|
4adc8a066d | ||
|
|
11cfc055af |
35
.claude/commands/dedupe.md
Normal file
35
.claude/commands/dedupe.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
allowed-tools: Bash(gh issue view:*), Bash(gh search:*), Bash(gh issue list:*), Bash(gh api:*), Bash(gh issue comment:*)
|
||||
description: Find duplicate GitHub issues
|
||||
---
|
||||
|
||||
Find up to 3 likely duplicate issues for a given GitHub issue.
|
||||
|
||||
To do this, follow these steps precisely:
|
||||
|
||||
1. Use an agent to check if the Github issue (a) is closed, (b) does not need to be deduped (eg. because it is broad product feedback without a specific solution, or positive feedback), or (c) already has a duplicates comment that you made earlier. If so, do not proceed.
|
||||
2. Use an agent to view a Github issue, and ask the agent to return a summary of the issue
|
||||
3. Then, launch 5 parallel agents to search Github for duplicates of this issue, using diverse keywords and search approaches, using the summary from #1
|
||||
4. Next, feed the results from #1 and #2 into another agent, so that it can filter out false positives, that are likely not actually duplicates of the original issue. If there are no duplicates remaining, do not proceed.
|
||||
5. Finally, comment back on the issue with a list of up to three duplicate issues (or zero, if there are no likely duplicates)
|
||||
|
||||
Notes (be sure to tell this to your agents, too):
|
||||
|
||||
- Use `gh` to interact with Github, rather than web fetch
|
||||
- Do not use other tools, beyond `gh` (eg. don't use other MCP servers, file edit, etc.)
|
||||
- Make a todo list first
|
||||
- For your comment, follow the following format precisely (assuming for this example that you found 3 suspected duplicates):
|
||||
|
||||
---
|
||||
|
||||
Found 3 possible duplicate issues:
|
||||
|
||||
1. <link to issue>
|
||||
2. <link to issue>
|
||||
3. <link to issue>
|
||||
|
||||
If your issue is a duplicate, please close it and 👍 the existing issue instead.
|
||||
|
||||
🤖 Generated with [Claude Code](https://claude.ai/code)
|
||||
|
||||
---
|
||||
@@ -3,8 +3,11 @@ FROM node:20
|
||||
ARG TZ
|
||||
ENV TZ="$TZ"
|
||||
|
||||
ARG CLAUDE_CODE_VERSION=latest
|
||||
|
||||
# Install basic development tools and iptables/ipset
|
||||
RUN apt update && apt install -y less \
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
less \
|
||||
git \
|
||||
procps \
|
||||
sudo \
|
||||
@@ -19,7 +22,10 @@ RUN apt update && apt install -y less \
|
||||
iproute2 \
|
||||
dnsutils \
|
||||
aggregate \
|
||||
jq
|
||||
jq \
|
||||
nano \
|
||||
vim \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Ensure default node user has access to /usr/local/share
|
||||
RUN mkdir -p /usr/local/share/npm-global && \
|
||||
@@ -42,10 +48,11 @@ RUN mkdir -p /workspace /home/node/.claude && \
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
ARG GIT_DELTA_VERSION=0.18.2
|
||||
RUN ARCH=$(dpkg --print-architecture) && \
|
||||
wget "https://github.com/dandavison/delta/releases/download/0.18.2/git-delta_0.18.2_${ARCH}.deb" && \
|
||||
sudo dpkg -i "git-delta_0.18.2_${ARCH}.deb" && \
|
||||
rm "git-delta_0.18.2_${ARCH}.deb"
|
||||
wget "https://github.com/dandavison/delta/releases/download/${GIT_DELTA_VERSION}/git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \
|
||||
sudo dpkg -i "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \
|
||||
rm "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb"
|
||||
|
||||
# Set up non-root user
|
||||
USER node
|
||||
@@ -54,11 +61,16 @@ USER node
|
||||
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
|
||||
ENV PATH=$PATH:/usr/local/share/npm-global/bin
|
||||
|
||||
# Set the default shell to bash rather than sh
|
||||
ENV SHELL /bin/zsh
|
||||
# Set the default shell to zsh rather than sh
|
||||
ENV SHELL=/bin/zsh
|
||||
|
||||
# Set the default editor and visual
|
||||
ENV EDITOR nano
|
||||
ENV VISUAL nano
|
||||
|
||||
# Default powerline10k theme
|
||||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.0/zsh-in-docker.sh)" -- \
|
||||
ARG ZSH_IN_DOCKER_VERSION=1.2.0
|
||||
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v${ZSH_IN_DOCKER_VERSION}/zsh-in-docker.sh)" -- \
|
||||
-p git \
|
||||
-p fzf \
|
||||
-a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \
|
||||
@@ -67,7 +79,8 @@ RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/
|
||||
-x
|
||||
|
||||
# Install Claude
|
||||
RUN npm install -g @anthropic-ai/claude-code
|
||||
RUN npm install -g @anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}
|
||||
|
||||
|
||||
# Copy and set up firewall script
|
||||
COPY init-firewall.sh /usr/local/bin/
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
"TZ": "${localEnv:TZ:America/Los_Angeles}"
|
||||
"TZ": "${localEnv:TZ:America/Los_Angeles}",
|
||||
"CLAUDE_CODE_VERSION": "latest",
|
||||
"GIT_DELTA_VERSION": "0.18.2",
|
||||
"ZSH_IN_DOCKER_VERSION": "1.2.0"
|
||||
}
|
||||
},
|
||||
"runArgs": [
|
||||
@@ -38,10 +41,10 @@
|
||||
},
|
||||
"remoteUser": "node",
|
||||
"mounts": [
|
||||
"source=claude-code-bashhistory,target=/commandhistory,type=volume",
|
||||
"source=claude-code-config,target=/home/node/.claude,type=volume"
|
||||
"source=claude-code-bashhistory-${devcontainerId},target=/commandhistory,type=volume",
|
||||
"source=claude-code-config-${devcontainerId},target=/home/node/.claude,type=volume"
|
||||
],
|
||||
"remoteEnv": {
|
||||
"containerEnv": {
|
||||
"NODE_OPTIONS": "--max-old-space-size=4096",
|
||||
"CLAUDE_CONFIG_DIR": "/home/node/.claude",
|
||||
"POWERLEVEL9K_DISABLE_GITSTATUS": "true"
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
set -euo pipefail # Exit on error, undefined vars, and pipeline failures
|
||||
IFS=$'\n\t' # Stricter word splitting
|
||||
|
||||
# 1. Extract Docker DNS info BEFORE any flushing
|
||||
DOCKER_DNS_RULES=$(iptables-save -t nat | grep "127\.0\.0\.11" || true)
|
||||
|
||||
# Flush existing rules and delete existing ipsets
|
||||
iptables -F
|
||||
iptables -X
|
||||
@@ -11,6 +14,16 @@ iptables -t mangle -F
|
||||
iptables -t mangle -X
|
||||
ipset destroy allowed-domains 2>/dev/null || true
|
||||
|
||||
# 2. Selectively restore ONLY internal Docker DNS resolution
|
||||
if [ -n "$DOCKER_DNS_RULES" ]; then
|
||||
echo "Restoring Docker DNS rules..."
|
||||
iptables -t nat -N DOCKER_OUTPUT 2>/dev/null || true
|
||||
iptables -t nat -N DOCKER_POSTROUTING 2>/dev/null || true
|
||||
echo "$DOCKER_DNS_RULES" | xargs -L 1 iptables -t nat
|
||||
else
|
||||
echo "No Docker DNS rules to restore"
|
||||
fi
|
||||
|
||||
# First allow DNS and localhost before any restrictions
|
||||
# Allow outbound DNS
|
||||
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
|
||||
@@ -88,7 +101,6 @@ echo "Host network detected as: $HOST_NETWORK"
|
||||
iptables -A INPUT -s "$HOST_NETWORK" -j ACCEPT
|
||||
iptables -A OUTPUT -d "$HOST_NETWORK" -j ACCEPT
|
||||
|
||||
# Set default policies to DROP first
|
||||
# Set default policies to DROP first
|
||||
iptables -P INPUT DROP
|
||||
iptables -P FORWARD DROP
|
||||
|
||||
136
.github/actions/claude-code-action/action.yml
vendored
136
.github/actions/claude-code-action/action.yml
vendored
@@ -1,136 +0,0 @@
|
||||
name: "Claude Code Action"
|
||||
description: "Run Claude Code in GitHub Actions workflows"
|
||||
|
||||
inputs:
|
||||
github_token:
|
||||
description: "GitHub token with repo and issues permissions"
|
||||
required: true
|
||||
anthropic_api_key:
|
||||
description: "Anthropic API key"
|
||||
required: true
|
||||
prompt:
|
||||
description: "The prompt to send to Claude Code"
|
||||
required: false
|
||||
default: ""
|
||||
prompt_file:
|
||||
description: "Path to a file containing the prompt to send to Claude Code"
|
||||
required: false
|
||||
default: ""
|
||||
allowed_tools:
|
||||
description: "Comma-separated list of allowed tools for Claude Code to use"
|
||||
required: false
|
||||
default: ""
|
||||
output_file:
|
||||
description: "File to save Claude Code output to (optional)"
|
||||
required: false
|
||||
default: ""
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for Claude Code execution"
|
||||
required: false
|
||||
default: "10"
|
||||
install_github_mcp:
|
||||
description: "Whether to install the GitHub MCP server"
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Claude Code
|
||||
shell: bash
|
||||
run: npm install -g @anthropic-ai/claude-code
|
||||
|
||||
- name: Install GitHub MCP Server
|
||||
if: inputs.install_github_mcp == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
claude mcp add-json github '{
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||
"ghcr.io/github/github-mcp-server:sha-ff3036d"
|
||||
],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ inputs.GITHUB_TOKEN }}"
|
||||
}
|
||||
}'
|
||||
|
||||
- name: Prepare Prompt File
|
||||
shell: bash
|
||||
id: prepare_prompt
|
||||
run: |
|
||||
# Check if either prompt or prompt_file is provided
|
||||
if [ -z "${{ inputs.prompt }}" ] && [ -z "${{ inputs.prompt_file }}" ]; then
|
||||
echo "::error::Neither 'prompt' nor 'prompt_file' was provided. At least one is required."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine which prompt source to use
|
||||
if [ ! -z "${{ inputs.prompt_file }}" ]; then
|
||||
# Check if the prompt file exists
|
||||
if [ ! -f "${{ inputs.prompt_file }}" ]; then
|
||||
echo "::error::Prompt file '${{ inputs.prompt_file }}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the provided prompt file
|
||||
PROMPT_PATH="${{ inputs.prompt_file }}"
|
||||
else
|
||||
mkdir -p /tmp/claude-action
|
||||
PROMPT_PATH="/tmp/claude-action/prompt.txt"
|
||||
echo "${{ inputs.prompt }}" > "$PROMPT_PATH"
|
||||
fi
|
||||
|
||||
# Verify the prompt file is not empty
|
||||
if [ ! -s "$PROMPT_PATH" ]; then
|
||||
echo "::error::Prompt is empty. Please provide a non-empty prompt."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save the prompt path for the next step
|
||||
echo "PROMPT_PATH=$PROMPT_PATH" >> $GITHUB_ENV
|
||||
|
||||
- name: Run Claude Code
|
||||
shell: bash
|
||||
id: run_claude
|
||||
run: |
|
||||
ALLOWED_TOOLS_ARG=""
|
||||
if [ ! -z "${{ inputs.allowed_tools }}" ]; then
|
||||
ALLOWED_TOOLS_ARG="--allowedTools ${{ inputs.allowed_tools }}"
|
||||
fi
|
||||
|
||||
# Set a timeout to ensure the command doesn't run indefinitely
|
||||
timeout_seconds=$((${{ inputs.timeout_minutes }} * 60))
|
||||
|
||||
if [ -z "${{ inputs.output_file }}" ]; then
|
||||
# Run Claude Code and output to console
|
||||
timeout $timeout_seconds claude \
|
||||
-p \
|
||||
--verbose \
|
||||
--output-format stream-json \
|
||||
"$(cat ${{ env.PROMPT_PATH }})" \
|
||||
${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }}
|
||||
else
|
||||
# Run Claude Code and tee output to console and file
|
||||
timeout $timeout_seconds claude \
|
||||
-p \
|
||||
--verbose \
|
||||
--output-format stream-json \
|
||||
"$(cat ${{ env.PROMPT_PATH }})" \
|
||||
${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }} | tee output.txt
|
||||
|
||||
# Process output.txt into JSON in a separate step
|
||||
jq -s '.' output.txt > output.json
|
||||
|
||||
# Extract the result from the last item in the array (system message)
|
||||
jq -r '.[-1].result' output.json > "${{ inputs.output_file }}"
|
||||
|
||||
echo "Complete output saved to output.json, final response saved to ${{ inputs.output_file }}"
|
||||
fi
|
||||
env:
|
||||
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
|
||||
GITHUB_TOKEN: ${{ inputs.github_token }}
|
||||
@@ -1,87 +0,0 @@
|
||||
name: "Claude Issue Triage Action"
|
||||
description: "Automatically triage GitHub issues using Claude Code"
|
||||
|
||||
inputs:
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for execution"
|
||||
required: false
|
||||
default: "5"
|
||||
anthropic_api_key:
|
||||
description: "Anthropic API key"
|
||||
required: true
|
||||
github_token:
|
||||
description: "GitHub token with repo and issues permissions"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Checkout repository code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create prompt file
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/claude-prompts
|
||||
cat > /tmp/claude-prompts/claude-issue-triage-prompt.txt << 'EOF'
|
||||
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: Don't post any comments or messages to the issue. Your only action should be to apply labels.
|
||||
|
||||
Issue Information:
|
||||
- REPO: ${{ github.repository }}
|
||||
- ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
|
||||
TASK OVERVIEW:
|
||||
|
||||
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
|
||||
|
||||
2. Next, use the GitHub tools to get context about the issue:
|
||||
- You have access to these tools:
|
||||
- mcp__github__get_issue: Use this to retrieve the current issue's details including title, description, and existing labels
|
||||
- mcp__github__get_issue_comments: Use this to read any discussion or additional context provided in the comments
|
||||
- mcp__github__update_issue: Use this to apply labels to the issue (do not use this for commenting)
|
||||
- mcp__github__search_issues: Use this to find similar issues that might provide context for proper categorization and to identify potential duplicate issues
|
||||
- mcp__github__list_issues: Use this to understand patterns in how other issues are labeled
|
||||
- Start by using mcp__github__get_issue to get the issue details
|
||||
|
||||
3. Analyze the issue content, considering:
|
||||
- The issue title and description
|
||||
- The type of issue (bug report, feature request, question, etc.)
|
||||
- Technical areas mentioned
|
||||
- Severity or priority indicators
|
||||
- User impact
|
||||
- Components affected
|
||||
|
||||
4. Select appropriate labels from the available labels list provided above:
|
||||
- Choose labels that accurately reflect the issue's nature
|
||||
- Be specific but comprehensive
|
||||
- Select priority labels if you can determine urgency (high-priority, med-priority, or low-priority)
|
||||
- Consider platform labels (android, ios) if applicable
|
||||
- If you find similar issues using mcp__github__search_issues, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
|
||||
|
||||
5. Apply the selected labels:
|
||||
- Use mcp__github__update_issue to apply your selected labels
|
||||
- DO NOT post any comments explaining your decision
|
||||
- DO NOT communicate directly with users
|
||||
- If no labels are clearly applicable, do not apply any labels
|
||||
|
||||
IMPORTANT GUIDELINES:
|
||||
- Be thorough in your analysis
|
||||
- Only select labels from the provided list above
|
||||
- DO NOT post any comments to the issue
|
||||
- Your ONLY action should be to apply labels using mcp__github__update_issue
|
||||
- It's okay to not add any labels if none are clearly applicable
|
||||
EOF
|
||||
|
||||
- name: Run Claude Code
|
||||
uses: ./.github/actions/claude-code-action
|
||||
with:
|
||||
prompt_file: /tmp/claude-prompts/claude-issue-triage-prompt.txt
|
||||
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
install_github_mcp: "true"
|
||||
timeout_minutes: ${{ inputs.timeout_minutes }}
|
||||
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
||||
github_token: ${{ inputs.github_token }}
|
||||
25
.github/workflows/claude-dedupe-issues.yml
vendored
Normal file
25
.github/workflows/claude-dedupe-issues.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Claude Issue Dedupe
|
||||
description: Automatically dedupe GitHub issues using Claude Code
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
claude-dedupe-issues:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run Claude Code slash command
|
||||
uses: anthropics/claude-code-base-action@beta
|
||||
with:
|
||||
prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number }}"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
claude_env: |
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
93
.github/workflows/claude-issue-triage.yml
vendored
93
.github/workflows/claude-issue-triage.yml
vendored
@@ -1,6 +1,5 @@
|
||||
name: Claude Issue Triage
|
||||
description: "Automatically triage GitHub issues using Claude Code"
|
||||
|
||||
description: Automatically triage GitHub issues using Claude Code
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
@@ -12,12 +11,96 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run Claude Issue Triage
|
||||
uses: ./.github/actions/claude-issue-triage-action
|
||||
- name: Create triage prompt
|
||||
run: |
|
||||
mkdir -p /tmp/claude-prompts
|
||||
cat > /tmp/claude-prompts/triage-prompt.txt << 'EOF'
|
||||
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: Don't post any comments or messages to the issue. Your only action should be to apply labels.
|
||||
|
||||
Issue Information:
|
||||
- REPO: ${{ github.repository }}
|
||||
- ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
|
||||
TASK OVERVIEW:
|
||||
|
||||
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
|
||||
|
||||
2. Next, use the GitHub tools to get context about the issue:
|
||||
- You have access to these tools:
|
||||
- mcp__github__get_issue: Use this to retrieve the current issue's details including title, description, and existing labels
|
||||
- mcp__github__get_issue_comments: Use this to read any discussion or additional context provided in the comments
|
||||
- mcp__github__update_issue: Use this to apply labels to the issue (do not use this for commenting)
|
||||
- mcp__github__search_issues: Use this to find similar issues that might provide context for proper categorization and to identify potential duplicate issues
|
||||
- mcp__github__list_issues: Use this to understand patterns in how other issues are labeled
|
||||
- Start by using mcp__github__get_issue to get the issue details
|
||||
|
||||
3. Analyze the issue content, considering:
|
||||
- The issue title and description
|
||||
- The type of issue (bug report, feature request, question, etc.)
|
||||
- Technical areas mentioned
|
||||
- Severity or priority indicators
|
||||
- User impact
|
||||
- Components affected
|
||||
|
||||
4. Select appropriate labels from the available labels list provided above:
|
||||
- Choose labels that accurately reflect the issue's nature
|
||||
- Be specific but comprehensive
|
||||
- Select priority labels if you can determine urgency (high-priority, med-priority, or low-priority)
|
||||
- Consider platform labels (android, ios) if applicable
|
||||
- If you find similar issues using mcp__github__search_issues, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
|
||||
|
||||
5. Apply the selected labels:
|
||||
- Use mcp__github__update_issue to apply your selected labels
|
||||
- DO NOT post any comments explaining your decision
|
||||
- DO NOT communicate directly with users
|
||||
- If no labels are clearly applicable, do not apply any labels
|
||||
|
||||
IMPORTANT GUIDELINES:
|
||||
- Be thorough in your analysis
|
||||
- Only select labels from the provided list above
|
||||
- DO NOT post any comments to the issue
|
||||
- Your ONLY action should be to apply labels using mcp__github__update_issue
|
||||
- It's okay to not add any labels if none are clearly applicable
|
||||
EOF
|
||||
|
||||
- name: Setup GitHub MCP Server
|
||||
run: |
|
||||
mkdir -p /tmp/mcp-config
|
||||
cat > /tmp/mcp-config/mcp-servers.json << 'EOF'
|
||||
{
|
||||
"mcpServers": {
|
||||
"github": {
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||
"ghcr.io/github/github-mcp-server:sha-7aced2b"
|
||||
],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Run Claude Code for Issue Triage
|
||||
uses: anthropics/claude-code-base-action@beta
|
||||
with:
|
||||
prompt_file: /tmp/claude-prompts/triage-prompt.txt
|
||||
allowed_tools: "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
|
||||
timeout_minutes: "5"
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
mcp_config: /tmp/mcp-config/mcp-servers.json
|
||||
claude_env: |
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
37
.github/workflows/claude.yml
vendored
Normal file
37
.github/workflows/claude.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
28
.github/workflows/lock-closed-issues.yml
vendored
Normal file
28
.github/workflows/lock-closed-issues.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: "Lock Stale Issues"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# 8am Pacific = 1pm UTC (2pm UTC during DST)
|
||||
- cron: "0 14 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: lock-threads
|
||||
|
||||
jobs:
|
||||
lock-threads:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
|
||||
with:
|
||||
issue-inactive-days: "7"
|
||||
process-only: "issues"
|
||||
log-output: true
|
||||
issue-comment: >
|
||||
This issue has been automatically locked since it was
|
||||
closed and has not had any activity for 7 days.
|
||||
If you're experiencing a similar issue, please file a new issue
|
||||
and reference this one if it's relevant.
|
||||
303
CHANGELOG.md
303
CHANGELOG.md
@@ -1,5 +1,308 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.64
|
||||
|
||||
- Agents: Added model customization support - you can now specify which model an agent should use
|
||||
- Agents: Fixed unintended access to the recursive agent tool
|
||||
- Hooks: Added systemMessage field to hook JSON output for displaying warnings and context
|
||||
- SDK: Fixed user input tracking across multi-turn conversations
|
||||
- Added hidden files to file search and @-mention suggestions
|
||||
|
||||
## 1.0.63
|
||||
|
||||
- Windows: Fixed file search, @agent mentions, and custom slash commands functionality
|
||||
|
||||
## 1.0.62
|
||||
|
||||
- Added @-mention support with typeahead for custom agents. @<your-custom-agent> to invoke it
|
||||
- Hooks: Added SessionStart hook for new session initialization
|
||||
- /add-dir command now supports typeahead for directory paths
|
||||
- Improved network connectivity check reliability
|
||||
|
||||
## 1.0.61
|
||||
|
||||
- Transcript mode (Ctrl+R): Changed Esc to exit transcript mode rather than interrupt
|
||||
- Settings: Added `--settings` flag to load settings from a JSON file
|
||||
- Settings: Fixed resolution of settings files paths that are symlinks
|
||||
- OTEL: Fixed reporting of wrong organization after authentication changes
|
||||
- Slash commands: Fixed permissions checking for allowed-tools with Bash
|
||||
- IDE: Added support for pasting images in VSCode MacOS using ⌘+V
|
||||
- IDE: Added `CLAUDE_CODE_AUTO_CONNECT_IDE=false` for disabling IDE auto-connection
|
||||
- Added `CLAUDE_CODE_SHELL_PREFIX` for wrapping Claude and user-provided shell commands run by Claude Code
|
||||
|
||||
## 1.0.60
|
||||
|
||||
- You can now create custom subagents for specialized tasks! Run /agents to get started
|
||||
|
||||
## 1.0.59
|
||||
|
||||
- SDK: Added tool confirmation support with canUseTool callback
|
||||
- SDK: Allow specifying env for spawned process
|
||||
- Hooks: Exposed PermissionDecision to hooks (including "ask")
|
||||
- Hooks: UserPromptSubmit now supports additionalContext in advanced JSON output
|
||||
- Fixed issue where some Max users that specified Opus would still see fallback to Sonnet
|
||||
|
||||
## 1.0.58
|
||||
|
||||
- Added support for reading PDFs
|
||||
- MCP: Improved server health status display in 'claude mcp list'
|
||||
- Hooks: Added CLAUDE_PROJECT_DIR env var for hook commands
|
||||
|
||||
## 1.0.57
|
||||
|
||||
- Added support for specifying a model in slash commands
|
||||
- Improved permission messages to help Claude understand allowed tools
|
||||
- Fix: Remove trailing newlines from bash output in terminal wrapping
|
||||
|
||||
## 1.0.56
|
||||
|
||||
- Windows: Enabled shift+tab for mode switching on versions of Node.js that support terminal VT mode
|
||||
- Fixes for WSL IDE detection
|
||||
- Fix an issue causing awsRefreshHelper changes to .aws directory not to be picked up
|
||||
|
||||
## 1.0.55
|
||||
|
||||
- Clarified knowledge cutoff for Opus 4 and Sonnet 4 models
|
||||
- Windows: fixed Ctrl+Z crash
|
||||
- SDK: Added ability to capture error logging
|
||||
- Add --system-prompt-file option to override system prompt in print mode
|
||||
|
||||
## 1.0.54
|
||||
|
||||
- Hooks: Added UserPromptSubmit hook and the current working directory to hook inputs
|
||||
- Custom slash commands: Added argument-hint to frontmatter
|
||||
- Windows: OAuth uses port 45454 and properly constructs browser URL
|
||||
- Windows: mode switching now uses alt + m, and plan mode renders properly
|
||||
- Shell: Switch to in-memory shell snapshot to fix file-related errors
|
||||
|
||||
## 1.0.53
|
||||
|
||||
- Updated @-mention file truncation from 100 lines to 2000 lines
|
||||
- Add helper script settings for AWS token refresh: awsAuthRefresh (for foreground operations like aws sso login) and awsCredentialExport (for background operation with STS-like response).
|
||||
|
||||
## 1.0.52
|
||||
|
||||
- Added support for MCP server instructions
|
||||
|
||||
## 1.0.51
|
||||
|
||||
- Added support for native Windows (requires Git for Windows)
|
||||
- Added support for Bedrock API keys through environment variable AWS_BEARER_TOKEN_BEDROCK
|
||||
- Settings: /doctor can now help you identify and fix invalid setting files
|
||||
- `--append-system-prompt` can now be used in interactive mode, not just --print/-p.
|
||||
- Increased auto-compact warning threshold from 60% to 80%
|
||||
- Fixed an issue with handling user directories with spaces for shell snapshots
|
||||
- OTEL resource now includes os.type, os.version, host.arch, and wsl.version (if running on Windows Subsystem for Linux)
|
||||
- Custom slash commands: Fixed user-level commands in subdirectories
|
||||
- Plan mode: Fixed issue where rejected plan from sub-task would get discarded
|
||||
|
||||
## 1.0.48
|
||||
|
||||
- Fixed a bug in v1.0.45 where the app would sometimes freeze on launch
|
||||
- Added progress messages to Bash tool based on the last 5 lines of command output
|
||||
- Added expanding variables support for MCP server configuration
|
||||
- Moved shell snapshots from /tmp to ~/.claude for more reliable Bash tool calls
|
||||
- Improved IDE extension path handling when Claude Code runs in WSL
|
||||
- Hooks: Added a PreCompact hook
|
||||
- Vim mode: Added c, f/F, t/T
|
||||
|
||||
## 1.0.45
|
||||
|
||||
- Redesigned Search (Grep) tool with new tool input parameters and features
|
||||
- Disabled IDE diffs for notebook files, fixing "Timeout waiting after 1000ms" error
|
||||
- Fixed config file corruption issue by enforcing atomic writes
|
||||
- Updated prompt input undo to Ctrl+\_ to avoid breaking existing Ctrl+U behavior, matching zsh's undo shortcut
|
||||
- Stop Hooks: Fixed transcript path after /clear and fixed triggering when loop ends with tool call
|
||||
- Custom slash commands: Restored namespacing in command names based on subdirectories. For example, .claude/commands/frontend/component.md is now /frontend:component, not /component.
|
||||
|
||||
## 1.0.44
|
||||
|
||||
- New /export command lets you quickly export a conversation for sharing
|
||||
- MCP: resource_link tool results are now supported
|
||||
- MCP: tool annotations and tool titles now display in /mcp view
|
||||
- Changed Ctrl+Z to suspend Claude Code. Resume by running `fg`. Prompt input undo is now Ctrl+U.
|
||||
|
||||
## 1.0.43
|
||||
|
||||
- Fixed a bug where the theme selector was saving excessively
|
||||
- Hooks: Added EPIPE system error handling
|
||||
|
||||
## 1.0.42
|
||||
|
||||
- Added tilde (`~`) expansion support to `/add-dir` command
|
||||
|
||||
## 1.0.41
|
||||
|
||||
- Hooks: Split Stop hook triggering into Stop and SubagentStop
|
||||
- Hooks: Enabled optional timeout configuration for each command
|
||||
- Hooks: Added "hook_event_name" to hook input
|
||||
- Fixed a bug where MCP tools would display twice in tool list
|
||||
- New tool parameters JSON for Bash tool in `tool_decision` event
|
||||
|
||||
## 1.0.40
|
||||
|
||||
- Fixed a bug causing API connection errors with UNABLE_TO_GET_ISSUER_CERT_LOCALLY if `NODE_EXTRA_CA_CERTS` was set
|
||||
|
||||
## 1.0.39
|
||||
|
||||
- New Active Time metric in OpenTelemetry logging
|
||||
|
||||
## 1.0.38
|
||||
|
||||
- Released hooks. Special thanks to community input in https://github.com/anthropics/claude-code/issues/712. Docs: https://docs.anthropic.com/en/docs/claude-code/hooks
|
||||
|
||||
## 1.0.37
|
||||
|
||||
- Remove ability to set `Proxy-Authorization` header via ANTHROPIC_AUTH_TOKEN or apiKeyHelper
|
||||
|
||||
## 1.0.36
|
||||
|
||||
- Web search now takes today's date into context
|
||||
- Fixed a bug where stdio MCP servers were not terminating properly on exit
|
||||
|
||||
## 1.0.35
|
||||
|
||||
- Added support for MCP OAuth Authorization Server discovery
|
||||
|
||||
## 1.0.34
|
||||
|
||||
- Fixed a memory leak causing a MaxListenersExceededWarning message to appear
|
||||
|
||||
## 1.0.33
|
||||
|
||||
- Improved logging functionality with session ID support
|
||||
- Added prompt input undo functionality (Ctrl+Z and vim 'u' command)
|
||||
- Improvements to plan mode
|
||||
|
||||
## 1.0.32
|
||||
|
||||
- Updated loopback config for litellm
|
||||
- Added forceLoginMethod setting to bypass login selection screen
|
||||
|
||||
## 1.0.31
|
||||
|
||||
- Fixed a bug where ~/.claude.json would get reset when file contained invalid JSON
|
||||
|
||||
## 1.0.30
|
||||
|
||||
- Custom slash commands: Run bash output, @-mention files, enable thinking with thinking keywords
|
||||
- Improved file path autocomplete with filename matching
|
||||
- Added timestamps in Ctrl-r mode and fixed Ctrl-c handling
|
||||
- Enhanced jq regex support for complex filters with pipes and select
|
||||
|
||||
## 1.0.29
|
||||
|
||||
- Improved CJK character support in cursor navigation and rendering
|
||||
|
||||
## 1.0.28
|
||||
|
||||
- Slash commands: Fix selector display during history navigation
|
||||
- Resizes images before upload to prevent API size limit errors
|
||||
- Added XDG_CONFIG_HOME support to configuration directory
|
||||
- Performance optimizations for memory usage
|
||||
- New attributes (terminal.type, language) in OpenTelemetry logging
|
||||
|
||||
## 1.0.27
|
||||
|
||||
- Streamable HTTP MCP servers are now supported
|
||||
- Remote MCP servers (SSE and HTTP) now support OAuth
|
||||
- MCP resources can now be @-mentioned
|
||||
- /resume slash command to switch conversations within Claude Code
|
||||
|
||||
## 1.0.25
|
||||
|
||||
- Slash commands: moved "project" and "user" prefixes to descriptions
|
||||
- Slash commands: improved reliability for command discovery
|
||||
- Improved support for Ghostty
|
||||
- Improved web search reliability
|
||||
|
||||
## 1.0.24
|
||||
|
||||
- Improved /mcp output
|
||||
- Fixed a bug where settings arrays got overwritten instead of merged
|
||||
|
||||
## 1.0.23
|
||||
|
||||
- Released TypeScript SDK: import @anthropic-ai/claude-code to get started
|
||||
- Released Python SDK: pip install claude-code-sdk to get started
|
||||
|
||||
## 1.0.22
|
||||
|
||||
- SDK: Renamed `total_cost` to `total_cost_usd`
|
||||
|
||||
## 1.0.21
|
||||
|
||||
- Improved editing of files with tab-based indentation
|
||||
- Fix for tool_use without matching tool_result errors
|
||||
- Fixed a bug where stdio MCP server processes would linger after quitting Claude Code
|
||||
|
||||
## 1.0.18
|
||||
|
||||
- Added --add-dir CLI argument for specifying additional working directories
|
||||
- Added streaming input support without require -p flag
|
||||
- Improved startup performance and session storage performance
|
||||
- Added CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR environment variable to freeze working directory for bash commands
|
||||
- Added detailed MCP server tools display (/mcp)
|
||||
- MCP authentication and permission improvements
|
||||
- Added auto-reconnection for MCP SSE connections on disconnect
|
||||
- Fixed issue where pasted content was lost when dialogs appeared
|
||||
|
||||
## 1.0.17
|
||||
|
||||
- We now emit messages from sub-tasks in -p mode (look for the parent_tool_use_id property)
|
||||
- Fixed crashes when the VS Code diff tool is invoked multiple times quickly
|
||||
- MCP server list UI improvements
|
||||
- Update Claude Code process title to display "claude" instead of "node"
|
||||
|
||||
## 1.0.11
|
||||
|
||||
- Claude Code can now also be used with a Claude Pro subscription
|
||||
- Added /upgrade for smoother switching to Claude Max plans
|
||||
- Improved UI for authentication from API keys and Bedrock/Vertex/external auth tokens
|
||||
- Improved shell configuration error handling
|
||||
- Improved todo list handling during compaction
|
||||
|
||||
## 1.0.10
|
||||
|
||||
- Added markdown table support
|
||||
- Improved streaming performance
|
||||
|
||||
## 1.0.8
|
||||
|
||||
- Fixed Vertex AI region fallback when using CLOUD_ML_REGION
|
||||
- Increased default otel interval from 1s -> 5s
|
||||
- Fixed edge cases where MCP_TIMEOUT and MCP_TOOL_TIMEOUT weren't being respected
|
||||
- Fixed a regression where search tools unnecessarily asked for permissions
|
||||
- Added support for triggering thinking non-English languages
|
||||
- Improved compacting UI
|
||||
|
||||
## 1.0.7
|
||||
|
||||
- Renamed /allowed-tools -> /permissions
|
||||
- Migrated allowedTools and ignorePatterns from .claude.json -> settings.json
|
||||
- Deprecated claude config commands in favor of editing settings.json
|
||||
- Fixed a bug where --dangerously-skip-permissions sometimes didn't work in --print mode
|
||||
- Improved error handling for /install-github-app
|
||||
- Bugfixes, UI polish, and tool reliability improvements
|
||||
|
||||
## 1.0.6
|
||||
|
||||
- Improved edit reliability for tab-indented files
|
||||
- Respect CLAUDE_CONFIG_DIR everywhere
|
||||
- Reduced unnecessary tool permission prompts
|
||||
- Added support for symlinks in @file typeahead
|
||||
- Bugfixes, UI polish, and tool reliability improvements
|
||||
|
||||
## 1.0.4
|
||||
|
||||
- Fixed a bug where MCP tool errors weren't being parsed correctly
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Added `DISABLE_INTERLEAVED_THINKING` to give users the option to opt out of interleaved thinking.
|
||||
- Improved model references to show provider-specific names (Sonnet 3.7 for Bedrock, Sonnet 4 for Console)
|
||||
- Updated documentation links and OAuth process descriptions
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- Claude Code is now generally available
|
||||
|
||||
37
README.md
37
README.md
@@ -4,44 +4,31 @@
|
||||
|
||||
[npm]: https://img.shields.io/npm/v/@anthropic-ai/claude-code.svg?style=flat-square
|
||||
|
||||
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
|
||||
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows -- all through natural language commands. Use it in your terminal, IDE, or tag @claude on Github.
|
||||
|
||||
Some of its key capabilities include:
|
||||
**Learn more in the [official documentation](https://docs.anthropic.com/en/docs/claude-code/overview)**.
|
||||
|
||||
- Edit files and fix bugs across your codebase
|
||||
- Answer questions about your code's architecture and logic
|
||||
- Execute and fix tests, lint, and other commands
|
||||
- Search through git history, resolve merge conflicts, and create commits and PRs
|
||||
|
||||
**Learn more in the [official documentation](https://docs.anthropic.com/en/docs/agents/claude-code/introduction)**.
|
||||
<img src="./demo.gif" />
|
||||
|
||||
## Get started
|
||||
|
||||
1. If you are new to Node.js and Node Package Manager (`npm`), then it is recommended that you configure an NPM prefix for your user.
|
||||
Instructions on how to do this can be found [here](https://docs.anthropic.com/en/docs/claude-code/troubleshooting#recommended-solution-create-a-user-writable-npm-prefix).
|
||||
1. Install Claude Code:
|
||||
|
||||
_Important_ We recommend installing this package as a non-privileged user, not as an administrative user like `root`.
|
||||
Installing as a non-privileged user helps maintain your system's security and stability.
|
||||
```sh
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
```
|
||||
|
||||
2. Install Claude Code:
|
||||
2. Navigate to your project directory and run `claude`.
|
||||
|
||||
```sh
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
```
|
||||
## Reporting Bugs
|
||||
|
||||
3. Navigate to your project directory and run <code>claude</code>.
|
||||
We welcome your feedback. Use the `/bug` command to report issues directly within Claude Code, or file a [GitHub issue](https://github.com/anthropics/claude-code/issues).
|
||||
|
||||
4. Complete the one-time OAuth process with your Anthropic Console account.
|
||||
|
||||
### Reporting Bugs
|
||||
|
||||
We welcome feedback during this beta period. Use the `/bug` command to report issues directly within Claude Code, or file a [GitHub issue](https://github.com/anthropics/claude-code/issues).
|
||||
|
||||
### Data collection, usage, and retention
|
||||
## Data collection, usage, and retention
|
||||
|
||||
When you use Claude Code, we collect feedback, which includes usage data (such as code acceptance or rejections), associated conversation data, and user feedback submitted via the `/bug` command.
|
||||
|
||||
#### How we use your data
|
||||
### How we use your data
|
||||
|
||||
We may use feedback to improve our products and services, but we will not train generative models using your feedback from Claude Code. Given their potentially sensitive nature, we store user feedback transcripts for only 30 days.
|
||||
|
||||
|
||||
148
Script/run_devcontainer_claude_code.ps1
Normal file
148
Script/run_devcontainer_claude_code.ps1
Normal file
@@ -0,0 +1,148 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Automates the setup and connection to a DevContainer environment using either Docker or Podman on Windows.
|
||||
|
||||
.DESCRIPTION
|
||||
This script automates the process of initializing, starting, and connecting to a DevContainer
|
||||
using either Docker or Podman as the container backend. It must be executed from the root
|
||||
directory of your project and assumes the script is located in a 'Script' subdirectory.
|
||||
|
||||
.PARAMETER Backend
|
||||
Specifies the container backend to use. Valid values are 'docker' or 'podman'.
|
||||
|
||||
.EXAMPLE
|
||||
.\Script\run_devcontainer_claude_code.ps1 -Backend docker
|
||||
Uses Docker as the container backend.
|
||||
|
||||
.EXAMPLE
|
||||
.\Script\run_devcontainer_claude_code.ps1 -Backend podman
|
||||
Uses Podman as the container backend.
|
||||
|
||||
.NOTES
|
||||
Project Structure:
|
||||
Project/
|
||||
├── .devcontainer/
|
||||
└── Script/
|
||||
└── run_devcontainer_claude_code.ps1
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateSet('docker','podman')]
|
||||
[string]$Backend
|
||||
)
|
||||
|
||||
# Notify script start
|
||||
Write-Host "--- DevContainer Startup & Connection Script ---"
|
||||
Write-Host "Using backend: $($Backend)"
|
||||
|
||||
# --- Prerequisite Check ---
|
||||
Write-Host "Checking for required commands..."
|
||||
try {
|
||||
Get-Command $Backend -ErrorAction Stop | Out-Null
|
||||
Write-Host "- $($Backend) command found."
|
||||
Get-Command devcontainer -ErrorAction Stop | Out-Null
|
||||
Write-Host "- devcontainer command found."
|
||||
}
|
||||
catch {
|
||||
Write-Error "A required command is not installed or not in your PATH."
|
||||
Write-Error "Please ensure '$($_.Exception.Message.Split(':')[0])' and 'devcontainer' are installed and accessible."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# --- Backend-Specific Initialization ---
|
||||
if ($Backend -eq 'podman') {
|
||||
Write-Host "--- Podman Backend Initialization ---"
|
||||
|
||||
# --- Step 1a: Initialize Podman machine ---
|
||||
Write-Host "Initializing Podman machine 'claudeVM'..."
|
||||
try {
|
||||
& podman machine init claudeVM
|
||||
Write-Host "Podman machine 'claudeVM' initialized or already exists."
|
||||
} catch {
|
||||
Write-Error "Failed to initialize Podman machine: $($_.Exception.Message)"
|
||||
exit 1 # Exit script on error
|
||||
}
|
||||
|
||||
# --- Step 1b: Start Podman machine ---
|
||||
Write-Host "Starting Podman machine 'claudeVM'..."
|
||||
try {
|
||||
& podman machine start claudeVM -q
|
||||
Write-Host "Podman machine started or already running."
|
||||
} catch {
|
||||
Write-Error "Failed to start Podman machine: $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Step 2: Set default connection ---
|
||||
Write-Host "Setting default Podman connection to 'claudeVM'..."
|
||||
try {
|
||||
& podman system connection default claudeVM
|
||||
Write-Host "Default connection set."
|
||||
} catch {
|
||||
Write-Warning "Failed to set default Podman connection (may be already set or machine issue): $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
} elseif ($Backend -eq 'docker') {
|
||||
Write-Host "--- Docker Backend Initialization ---"
|
||||
|
||||
# --- Step 1 & 2: Check Docker Desktop ---
|
||||
Write-Host "Checking if Docker Desktop is running and docker command is available..."
|
||||
try {
|
||||
docker info | Out-Null
|
||||
Write-Host "Docker Desktop (daemon) is running."
|
||||
} catch {
|
||||
Write-Error "Docker Desktop is not running or docker command not found."
|
||||
Write-Error "Please ensure Docker Desktop is running."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# --- Step 3: Bring up DevContainer ---
|
||||
Write-Host "Bringing up DevContainer in the current folder..."
|
||||
try {
|
||||
$arguments = @('up', '--workspace-folder', '.')
|
||||
if ($Backend -eq 'podman') {
|
||||
$arguments += '--docker-path', 'podman'
|
||||
}
|
||||
& devcontainer @arguments
|
||||
Write-Host "DevContainer startup process completed."
|
||||
} catch {
|
||||
Write-Error "Failed to bring up DevContainer: $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Step 4: Get DevContainer ID ---
|
||||
Write-Host "Finding the DevContainer ID..."
|
||||
$currentFolder = (Get-Location).Path
|
||||
|
||||
try {
|
||||
$containerId = (& $Backend ps --filter "label=devcontainer.local_folder=$currentFolder" --format '{{.ID}}').Trim()
|
||||
} catch {
|
||||
$displayCommand = "$Backend ps --filter `"label=devcontainer.local_folder=$currentFolder`" --format '{{.ID}}'"
|
||||
Write-Error "Failed to get container ID (Command: $displayCommand): $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not $containerId) {
|
||||
Write-Error "Could not find DevContainer ID for the current folder ('$currentFolder')."
|
||||
Write-Error "Please check if 'devcontainer up' was successful and the container is running."
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Found container ID: $containerId"
|
||||
|
||||
# --- Step 5 & 6: Execute command and enter interactive shell inside container ---
|
||||
Write-Host "Executing 'claude' command and then starting zsh session inside container $($containerId)..."
|
||||
try {
|
||||
& $Backend exec -it $containerId zsh -c 'claude; exec zsh'
|
||||
Write-Host "Interactive session ended."
|
||||
} catch {
|
||||
$displayCommand = "$Backend exec -it $containerId zsh -c 'claude; exec zsh'"
|
||||
Write-Error "Failed to execute command inside container (Command: $displayCommand): $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Notify script completion
|
||||
Write-Host "--- Script completed ---"
|
||||
83
examples/hooks/bash_command_validator_example.py
Normal file
83
examples/hooks/bash_command_validator_example.py
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Claude Code Hook: Bash Command Validator
|
||||
=========================================
|
||||
This hook runs as a PreToolUse hook for the Bash tool.
|
||||
It validates bash commands against a set of rules before execution.
|
||||
In this case it changes grep calls to using rg.
|
||||
|
||||
Read more about hooks here: https://docs.anthropic.com/en/docs/claude-code/hooks
|
||||
|
||||
Make sure to change your path to your actual script.
|
||||
|
||||
{
|
||||
"hooks": {
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "Bash",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "python3 /path/to/claude-code/examples/hooks/bash_command_validator_example.py"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Define validation rules as a list of (regex pattern, message) tuples
|
||||
_VALIDATION_RULES = [
|
||||
(
|
||||
r"^grep\b(?!.*\|)",
|
||||
"Use 'rg' (ripgrep) instead of 'grep' for better performance and features",
|
||||
),
|
||||
(
|
||||
r"^find\s+\S+\s+-name\b",
|
||||
"Use 'rg --files | rg pattern' or 'rg --files -g pattern' instead of 'find -name' for better performance",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def _validate_command(command: str) -> list[str]:
|
||||
issues = []
|
||||
for pattern, message in _VALIDATION_RULES:
|
||||
if re.search(pattern, command):
|
||||
issues.append(message)
|
||||
return issues
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
input_data = json.load(sys.stdin)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Error: Invalid JSON input: {e}", file=sys.stderr)
|
||||
# Exit code 1 shows stderr to the user but not to Claude
|
||||
sys.exit(1)
|
||||
|
||||
tool_name = input_data.get("tool_name", "")
|
||||
if tool_name != "Bash":
|
||||
sys.exit(0)
|
||||
|
||||
tool_input = input_data.get("tool_input", {})
|
||||
command = tool_input.get("command", "")
|
||||
|
||||
if not command:
|
||||
sys.exit(0)
|
||||
|
||||
issues = _validate_command(command)
|
||||
if issues:
|
||||
for message in issues:
|
||||
print(f"• {message}", file=sys.stderr)
|
||||
# Exit code 2 blocks tool call and shows stderr to Claude
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user