From 5dc496c6b92686114ba3ff11b9944fda7f37131f Mon Sep 17 00:00:00 2001 From: Damien Daspit Date: Thu, 1 Oct 2026 14:56:43 -0400 Subject: [PATCH 1/3] Let Claude read the C# source when porting port-pr reads the C# code from a sibling clone at ../machine, which the @claude workflow never created. Claude could not check C# behavior on #390. The workflow now clones sillsdev/machine with full history, and Claude can read it and run git show, log and blame there. port-pr reads each file as of the source PR's merge commit. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/port-pr/SKILL.md | 9 +++++---- .github/workflows/claude.yml | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.claude/skills/port-pr/SKILL.md b/.claude/skills/port-pr/SKILL.md index 4fe0b391..fcb1e1ce 100644 --- a/.claude/skills/port-pr/SKILL.md +++ b/.claude/skills/port-pr/SKILL.md @@ -32,13 +32,14 @@ gh issue view --json title,body,labels ## Step 2 — Understand the source change ```bash -gh pr view --repo sillsdev/machine --json title,body,files,commits +gh pr view --repo sillsdev/machine --json title,body,files,commits,mergeCommit gh pr diff --repo sillsdev/machine ``` -Read the full diff. For each changed C# file, open the corresponding file(s) in -`../machine` to understand the surrounding context, and identify the Python counterpart -(see mapping below). Read the existing Python code you're about to change so the port +Read the full diff. For each changed C# file, read the corresponding file(s) in +`../machine` as of the merge commit, with `git -C ../machine show :`, +to understand the surrounding context. The working tree may have moved on since the PR +merged. Identify the Python counterpart (see mapping below). Read the existing Python code you're about to change so the port matches local idiom. Note: not every change ports. Skip C#-only concerns (`.csproj`/`.sln`/`Directory.*.props`, diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 7a4cfd18..e8915199 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -70,6 +70,11 @@ jobs: - name: Install dependencies run: poetry install --no-interaction --all-extras + # port-pr reads the C# source from a sibling clone, as of each source PR's merge + # commit, so it needs full history. Outside the workspace, black and flake8 skip it. + - name: Clone sillsdev/machine + run: git clone https://github.com/sillsdev/machine.git ../machine + - name: Run Claude Code id: claude uses: anthropics/claude-code-action@v1 @@ -83,7 +88,8 @@ jobs: # The action's own prompt ends an issue run with a "Create a PR" link; the # appended prompt has Claude open the pull request itself. claude_args: >- - --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh issue view:*),Bash(git log:*),Bash(git blame:*),Bash(git show:*),Bash(git diff:*),Bash(git status:*),Bash(poetry run:*),Bash(./local_check.sh:*)" + --add-dir ../machine + --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh issue view:*),Bash(git log:*),Bash(git blame:*),Bash(git show:*),Bash(git diff:*),Bash(git status:*),Bash(git -C ../machine show:*),Bash(git -C ../machine log:*),Bash(git -C ../machine blame:*),Bash(poetry run:*),Bash(./local_check.sh:*)" --append-system-prompt "When invoked on an issue and you change code, open the pull request yourself once your commits are pushed: gh pr create --base main --head . Post its link in your comment in place of a Create a PR link. Write the title and body with the pr-authoring skill, and put Closes # in the body. Before opening it, run ./local_check.sh --agent-strict and report its result in the body. Dependencies are already installed, and you work on the branch this action created: where a skill such as port-pr says to install, create or switch branches, or push, commit on the current branch and push it the way these instructions say." # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md # or https://code.claude.com/docs/en/cli-reference for available options From 5cbf917a24d2d62638c0dd13737405c1de43b52b Mon Sep 17 00:00:00 2001 From: Damien Daspit Date: Thu, 1 Oct 2026 16:15:16 -0400 Subject: [PATCH 2/3] Fetch a stale C# clone before reading the merge commit A local ../machine clone fetched before the source PR merged cannot resolve the merge commit. port-pr now fetches and retries when git show reports a bad object. The workflow makes a fresh clone, so this only affects local runs. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/port-pr/SKILL.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.claude/skills/port-pr/SKILL.md b/.claude/skills/port-pr/SKILL.md index fcb1e1ce..b316efaf 100644 --- a/.claude/skills/port-pr/SKILL.md +++ b/.claude/skills/port-pr/SKILL.md @@ -39,8 +39,10 @@ gh pr diff --repo sillsdev/machine Read the full diff. For each changed C# file, read the corresponding file(s) in `../machine` as of the merge commit, with `git -C ../machine show :`, to understand the surrounding context. The working tree may have moved on since the PR -merged. Identify the Python counterpart (see mapping below). Read the existing Python code you're about to change so the port -matches local idiom. +merged. If `git show` reports `bad object`, the clone predates the merge: run +`git -C ../machine fetch` and retry. Identify the Python counterpart (see mapping +below). Read the existing Python code you're about to change so the port matches local +idiom. Note: not every change ports. Skip C#-only concerns (`.csproj`/`.sln`/`Directory.*.props`, `AssemblyInfo`, `omnisharp.json`, csharpier/editorconfig formatting, NuGet packaging). From db028b1ec7e695efd797b0e67965bb37358bfffe Mon Sep 17 00:00:00 2001 From: Damien Daspit Date: Thu, 1 Oct 2026 16:23:09 -0400 Subject: [PATCH 3/3] Check for the merge commit before reading the C# clone git show : reports a missing commit as a path error, never as bad object, so the retry in port-pr never triggered. The skill now checks the commit with git cat-file -e and fetches when it is missing. The workflow allows cat-file in the clone so a run that follows the skill is not denied. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/port-pr/SKILL.md | 8 ++++---- .github/workflows/claude.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.claude/skills/port-pr/SKILL.md b/.claude/skills/port-pr/SKILL.md index b316efaf..dcd3eb04 100644 --- a/.claude/skills/port-pr/SKILL.md +++ b/.claude/skills/port-pr/SKILL.md @@ -39,10 +39,10 @@ gh pr diff --repo sillsdev/machine Read the full diff. For each changed C# file, read the corresponding file(s) in `../machine` as of the merge commit, with `git -C ../machine show :`, to understand the surrounding context. The working tree may have moved on since the PR -merged. If `git show` reports `bad object`, the clone predates the merge: run -`git -C ../machine fetch` and retry. Identify the Python counterpart (see mapping -below). Read the existing Python code you're about to change so the port matches local -idiom. +merged. First check the commit with `git -C ../machine cat-file -e `. If it +fails, the clone predates the merge: run `git -C ../machine fetch`. Identify the Python +counterpart (see mapping below). Read the existing Python code you're about to change so +the port matches local idiom. Note: not every change ports. Skip C#-only concerns (`.csproj`/`.sln`/`Directory.*.props`, `AssemblyInfo`, `omnisharp.json`, csharpier/editorconfig formatting, NuGet packaging). diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index e8915199..dee8cc3e 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -89,7 +89,7 @@ jobs: # appended prompt has Claude open the pull request itself. claude_args: >- --add-dir ../machine - --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh issue view:*),Bash(git log:*),Bash(git blame:*),Bash(git show:*),Bash(git diff:*),Bash(git status:*),Bash(git -C ../machine show:*),Bash(git -C ../machine log:*),Bash(git -C ../machine blame:*),Bash(poetry run:*),Bash(./local_check.sh:*)" + --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh issue view:*),Bash(git log:*),Bash(git blame:*),Bash(git show:*),Bash(git diff:*),Bash(git status:*),Bash(git -C ../machine show:*),Bash(git -C ../machine cat-file:*),Bash(git -C ../machine log:*),Bash(git -C ../machine blame:*),Bash(poetry run:*),Bash(./local_check.sh:*)" --append-system-prompt "When invoked on an issue and you change code, open the pull request yourself once your commits are pushed: gh pr create --base main --head . Post its link in your comment in place of a Create a PR link. Write the title and body with the pr-authoring skill, and put Closes # in the body. Before opening it, run ./local_check.sh --agent-strict and report its result in the body. Dependencies are already installed, and you work on the branch this action created: where a skill such as port-pr says to install, create or switch branches, or push, commit on the current branch and push it the way these instructions say." # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md # or https://code.claude.com/docs/en/cli-reference for available options