johnnystefan/test-saas-business/pattern-state

Claude Code and agent skill by johnnystefan/test-saas-business

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Teaches and applies the State behavioral design pattern — allowing an object to alter its behavior when its internal state changes, appearing as if the object changed its class. Trigger: When implementing finite state machines, workflow states, or mode-based behavior.

Install

npx vskill@latest install johnnystefan/test-saas-business/pattern-state

SKILL.md

The same SKILL.md was published earlier as johnnystefan/test-saas-business/pattern-state.

Skill: Implement State Pattern

Purpose

Allows an object to alter its behavior when its internal state changes. It appears as if the object changed its class.

Procedural Instructions

  1. Map Finite States: Identify the possible states and transitions.
  2. Declare State Interface: Define methods for all state-dependent actions.
  3. Create Concrete State Classes: Extract logic from the original class into these new classes, one per state.
  4. Define Context: The original class (Context) stores a reference to a state object and delegates work to it.
  5. Manage Transitions: Either the Context or the states themselves can trigger a state change.

TypeScript Example

typescript
interface State {
handle(context: Context): void;
}
class Context {
constructor(private state: State) {}
transitionTo(state: State) {
this.state = state;
}
request() {
this.state.handle(this);
}
}
class ConcreteStateA implements State {
handle(context: Context) {
context.transitionTo(new ConcreteStateB());
}
}

Payoff

  • SRP: Organizes state-specific code into separate classes.
  • Simplified Logic: Eliminates massive, complex conditionals based on state flags.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/johnnystefan/test-saas-business/pattern-state/badge)](https://verified-skill.com/skills/johnnystefan/test-saas-business/pattern-state)

Something wrong with this skill or its page? Tell us.