docs(rules): avoid if/Test-Path file checks that prompt#755
Merged
Conversation
session-resume.md phrased the resume check as "if resume.md
exists", which leads to an if (Test-Path) { Get-Content } else
compound command whose if first token erodes the matchable
prefix and triggers a permission prompt. Steer the rule to the
Read tool and add a cheatsheet row mapping the conditional
file-existence pattern to the Read tool (or Get-Content with
-ErrorAction SilentlyContinue).
Closes #754
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Steers
session-resume.mdand theenvironment.mdcheatsheet away fromif/Test-Pathcompound file-existence checks toward the Read tool.Why
Closes #754.
Follow-up to #752. The #752 cheatsheet is prevention; it cannot stop prompts when
a rule itself induces a compound command.
session-resume.mdphrased the resumecheck as "if resume.md exists", so the agent built an
if (Test-Path) { Get-Content } elsecommand whoseiffirst token erodes thematchable prefix and triggers a permission prompt. This is the structure /
prefix-erosion axis, independent of the #750 length axis.
How
.claude/resume.md;a not-found error means no resume file; do not wrap the check in
if/Test-Path.if (Test-Path X) { Get-Content X } else {...}-> Read tool on X(or
Get-Content X -ErrorAction SilentlyContinue).Where
project/.claude/rules/workflow/session-resume.mdproject/.claude/rules/core/environment.mdTest
Verified prompt-free: the Read tool and
Get-Content X -ErrorAction SilentlyContinueboth run without a permission prompt (the original
if/elseform prompted). Nosettings.json/settings.windows.jsonpermissionsentries touched, sotests/scripts/test-windows-powershell-permissions.shand the narrow WindowsPowerShell allow policy are unaffected.
Closes #754