Skip to content

Add CLAUDE.md and Claude slash commands for common workflows#10

Open
nsprenkle wants to merge 7 commits intomasterfrom
nsprenkle/claude-init
Open

Add CLAUDE.md and Claude slash commands for common workflows#10
nsprenkle wants to merge 7 commits intomasterfrom
nsprenkle/claude-init

Conversation

@nsprenkle
Copy link
Copy Markdown
Member

@nsprenkle nsprenkle commented Mar 4, 2026

Adds Claude Code project configuration and slash commands to streamline common development workflows.

Changes

  • Added CLAUDE.md with project guidance for Claude Code: build commands, architecture overview, and PR requirements
  • Added .claude/commands/test.md/test command to run the Sphinx build, report errors, and auto-fix simple issues
  • Added .claude/commands/pr-description.md/pr-description command to generate a filled-in PR description from commit history
  • Added .claude/commands/pr.md/pr command to generate, review, and create a pull request including a security scan step

Date Needed (optional)

Reviewers

Possible roles follow. The PR submitter checks the boxes after each reviewer finishes and gives 👍.

Copilot AI review requested due to automatic review settings March 4, 2026 20:13
This helps the changeset work even if local master isn't up to date.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Claude Code configuration and reusable slash commands to standardize common workflows (running docs builds, generating PR descriptions, and creating PRs) for this Sphinx documentation repository.

Changes:

  • Added CLAUDE.md with repository context, build commands, architecture notes, and PR expectations.
  • Added Claude slash commands for /test, /pr-description, and /pr under .claude/commands/.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
CLAUDE.md Documents local build/test commands and high-level repo architecture for Claude Code usage.
.claude/commands/test.md Defines a /test workflow to run ./run_tests.sh, summarize results, and guide fixes.
.claude/commands/pr-description.md Defines a /pr-description workflow to generate PR text from commits/diff + template.
.claude/commands/pr.md Defines a /pr workflow to draft and create PRs (includes a basic secrets scan step).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 4, 2026 20:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +31 to +38
7. If confirmed, push the current branch to `origin` if it hasn't been pushed yet (run `git push -u origin HEAD`).
8. Determine the target repo by running `gh repo view --json nameWithOwner -q .nameWithOwner` to derive it from the current git remote. Write the PR body to a temp file and create the PR using:
```
cat > /tmp/pr-body.md << 'EOF'
<description>
EOF
gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md
rm /tmp/pr-body.md
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

Step 8 derives <nameWithOwner> from the current repo, but step 1–3 still assume origin/master and step 37 hard-codes --base master. If the base branch differs or the repo is a fork, this can create PRs against the wrong base. Consider deriving the base branch name from the target repo (and/or local default branch ref) and using it for both the diff range and the gh pr create --base argument.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +38
8. Determine the target repo by running `gh repo view --json nameWithOwner -q .nameWithOwner` to derive it from the current git remote. Write the PR body to a temp file and create the PR using:
```
cat > /tmp/pr-body.md << 'EOF'
<description>
EOF
gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md
rm /tmp/pr-body.md
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

Writing the PR body to a fixed path (/tmp/pr-body.md) risks clobbering an existing file and can be unsafe on multi-user systems (symlink/hardlink attacks). Prefer creating a unique temp file (e.g., via mktemp) and cleaning it up reliably (e.g., with a shell trap) after gh pr create runs.

Suggested change
8. Determine the target repo by running `gh repo view --json nameWithOwner -q .nameWithOwner` to derive it from the current git remote. Write the PR body to a temp file and create the PR using:
```
cat > /tmp/pr-body.md << 'EOF'
<description>
EOF
gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md
rm /tmp/pr-body.md
8. Determine the target repo by running `gh repo view --json nameWithOwner -q .nameWithOwner` to derive it from the current git remote. Write the PR body to a securely created temp file and create the PR using:

pr_body_file="$(mktemp)"
trap 'rm -f "$pr_body_file"' EXIT
cat > "$pr_body_file" << 'EOF'

EOF
gh pr create --repo --base master --title "<title>" --body-file "$pr_body_file"

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +37
cat > /tmp/pr-body.md << 'EOF'
<description>
EOF
gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The command gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md interpolates the generated PR title directly into a double-quoted shell argument, which can lead to command injection if <title> ever contains shell metacharacters such as $(), backticks, or unbalanced quotes derived from commit messages or other untrusted text. An attacker who controls commit messages or branch metadata could craft content that, when used to build <title>, causes arbitrary commands to execute when this snippet is run in a shell. To avoid this, ensure the title is passed to gh without going through the shell for interpolation (for example by using a safe argument-passing mechanism or robust escaping/quoting rather than embedding it directly in a double-quoted shell string).

Suggested change
cat > /tmp/pr-body.md << 'EOF'
<description>
EOF
gh pr create --repo <nameWithOwner> --base master --title "<title>" --body-file /tmp/pr-body.md
python - << 'PY'
import subprocess
import textwrap
name_with_owner = "<nameWithOwner>"
title = "<title>"
body = textwrap.dedent("""<description>
""").lstrip()
with open("/tmp/pr-body.md", "w", encoding="utf-8") as f:
f.write(body)
subprocess.run(
[
"gh",
"pr",
"create",
"--repo",
name_with_owner,
"--base",
"master",
"--title",
title,
"--body-file",
"/tmp/pr-body.md",
],
check=True,
)
PY

Copilot uses AI. Check for mistakes.
@nsprenkle nsprenkle requested review from jansenk and jristau1984 March 6, 2026 21:19
Copy link
Copy Markdown
Member

@michaelroytman michaelroytman left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@jansenk
Copy link
Copy Markdown
Member

jansenk commented Mar 18, 2026

This is neat. Could you point me to what exactly the claude "commands" are / how they work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants