Skip to content

fix(pstack): make a brand with a type guard, not as - #700

Merged
poteto merged 1 commit into
mainfrom
lauren/pstack-brand-type-guard-31fc
Oct 17, 2026
Merged

poteto merged 1 commit into
mainfrom
lauren/pstack-brand-type-guard-31fc

Conversation

@poteto

@poteto poteto commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The branded-type example in typescript-best-practices built its brand with return input as AgentId, which the skill's "No as casts" row tells agents to avoid. Agents copy the example, so it taught the cast the rules forbid.

What changed

  • parseAgentId now narrows through an isAgentId type guard and returns the input with no cast.
  • The "Branded types" row says a brand comes from a verifying type guard (input is AgentId), never from as.

Scope

  • pstack/skills/typescript-best-practices and its regenerated Claude Code copy.
  • Does not change the general cast rules, which still allow as after validation.

Blast Radius

Only the text agents read for TypeScript edits changes. No code, build, or runtime path changes.

Verification

  • A strict TypeScript compile of the new example has no as and no errors. It still rejects a raw string where an AgentId is expected.
  • node scripts/validate-plugins.mjs passes, and node scripts/generate-pstack-harness-trees.mjs --check reports 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 as casts 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 from as. The patterns.md example adds isAgentId, uses it in parseAgentId, 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.

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`.
@poteto
poteto marked this pull request as ready for review October 17, 2026 19:06
@poteto
poteto merged commit 0317eb8 into main Oct 17, 2026
2 checks passed
@poteto
poteto deleted the lauren/pstack-brand-type-guard-31fc branch October 17, 2026 19:06
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.

1 participant