Repository navigation
fix(pstack): make a brand with a type guard, not as - #700
Merged
Merged
Conversation
The branded-type example built its brand with `as`, which the skill's "No `as` casts" row tells agents to avoid. parseAgentId now narrows through an isAgentId type guard and returns the input with no cast, and the Branded types row says a brand comes from a verifying type guard, never from `as`.
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.
Why
The branded-type example in
typescript-best-practicesbuilt its brand withreturn input as AgentId, which the skill's "Noascasts" row tells agents to avoid. Agents copy the example, so it taught the cast the rules forbid.What changed
parseAgentIdnow narrows through anisAgentIdtype guard and returns the input with no cast.input is AgentId), never fromas.Scope
pstack/skills/typescript-best-practicesand its regenerated Claude Code copy.asafter validation.Blast Radius
Only the text agents read for TypeScript edits changes. No code, build, or runtime path changes.
Verification
asand no errors. It still rejects a raw string where anAgentIdis expected.node scripts/validate-plugins.mjspasses, andnode scripts/generate-pstack-harness-trees.mjs --checkreports the harness tree up to date.Note
Low Risk
Documentation-only changes to agent skill text; no application code, build, or runtime behavior.
Overview
Aligns the typescript-best-practices branded-type guidance with the skill’s own No
ascasts rule so agents don’t copy a forbidden pattern.The Branded types table row now states that a brand must come from a verifying type guard (
input is AgentId), not fromas. Thepatterns.mdexample addsisAgentId, uses it inparseAgentId, and returns the narrowed string without a cast.Reviewed by Cursor Bugbot for commit 4c18caa. Bugbot is set up for automated code reviews on this repo. Configure here.