Laravel Advanced Concepts logo

Laravel Advanced Concepts

Community
peterfox
laravel-advanced-concepts

Advanced Laravel architectural patterns: Feature Flags, State Machines, and Event Sourcing. Use this skill whenever a user asks about: toggling features for users/groups, gradual rollouts, A/B testing, beta access (→ Feature Flags); modeling workflows like order status, subscription lifecycle, booking states, anything with defined transitions (→ State Machines); financial ledgers, credit/wallet systems, audit trails, undo history, GDPR-compliant data deletion, analytics replay (→ Event Sourcing). Also trigger when users mention spatie/laravel-model-states, Laravel Pennant, spatie/laravel-event-sourcing, hirethunk/verbs, or ask "how should I model X in Laravel" for any complex domain. This skill provides library recommendations, code patterns, and decision guidance — use it proactively whenever the user's domain sounds like it fits one of these patterns.

Overview

Publisherpeterfox
Repositoryagent-skills
Skill namelaravel-advanced-concepts
Stars
25
Forks
0
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by peterfox on GitHub. Read the source before you install it.

Installation

Install the Laravel Advanced Concepts AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/peterfox/agent-skills/tree/main/laravel-advanced-concepts
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/peterfox/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/laravel-advanced-concepts .claude/skills/laravel-advanced-concepts
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Laravel Advanced Concepts in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Laravel Advanced Concepts on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Laravel Advanced Concepts is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Laravel Advanced Concepts

Three patterns that solve common but complex problems in Laravel apps. Each has a clear "home turf" — when the problem fits the pattern well, you get enormous benefits; when it doesn't, you're adding accidental complexity.

Quick Pattern Selector

SituationPatternWhy
Credit, wallet, points, ledgerEvent SourcingEvery balance change needs an immutable audit trail; balance = sum of events
Order status, booking lifecycleState MachineTransitions are the business rules; illegal transitions must be prevented at the model level
New feature rollout, beta accessFeature FlagsDecouple deploy from release; control who sees what without code changes
GDPR "right to be forgotten"Event SourcingEncrypt events per user; "forget" = destroy the key
Subscription plan managementState Machineactive → paused → cancelled is a classic FSM
A/B testing, experimentsFeature FlagsDefine variant logic once, measure separately
Full audit log / time travelEvent SourcingRebuild state at any point in time from the event stream

Feature Flags

Primary library: Laravel Pennant (official, first-party, Laravel 10.2+)

Pennant is the recommended choice for almost all use cases. It ships with Laravel and has first-class support.

When to use Feature Flags

  • Rolling out a new feature to a percentage of users
  • Beta programs / early access lists
  • A/B testing UI or pricing
  • Kill switches for risky features
  • Gradual infrastructure migrations (e.g., "10% of traffic uses new payment processor")

Core concepts

  • Feature: a named flag that resolves to true/false (or a variant value)
  • Scope: what the flag is evaluated against — usually the authenticated user, but can be any model
  • Driver: where flag state is stored — database (per-scope state), array (in-memory for tests)

See references/feature-flags.md for installation, full API, and patterns.


State Machines

Primary library: spatie/laravel-model-states

The standard choice for Laravel. Tight Eloquent integration, transition validation, custom transition classes.

When to use State Machines

  • The entity has a status field that controls what actions are allowed
  • Illegal transitions should be rejected (e.g., can't go from cancelled back to active)
  • You want the transition itself to carry logic (send email, fire event, update timestamps)
  • Multiple places in your code change the same status and you need consistency

When NOT to use State Machines

  • The "states" are just labels with no transition logic — a plain enum is simpler
  • Transitions are completely unrestricted — just update the field directly

See references/state-machines.md for installation, state/transition classes, and patterns.


Event Sourcing

Primary libraries:

When to use Event Sourcing

  • Financial data: credits, debits, wallet balances, points — the canonical use case
  • You need a complete audit log that cannot be altered
  • You need to replay history to rebuild state (analytics, projections, debugging)
  • GDPR compliance: per-user encryption keys let you "forget" a user by deleting their key
  • The domain is complex enough that understanding "how did we get here" matters

When NOT to use Event Sourcing

  • Simple CRUD with no audit requirements — overhead isn't worth it
  • The team is unfamiliar with event sourcing — it's a significant mental model shift
  • You just need soft deletes + timestamps — that's usually enough

Choosing between Spatie and Verbs

  • Spatie: battle-tested, more users/resources, traditional event sourcing concepts (Aggregates, Projectors, Reactors)
  • Verbs: simpler syntax, type-safe state, better for greenfield projects, fewer concepts to learn

See references/event-sourcing.md for installation, aggregates, projectors, and patterns for both libraries.


Combining Patterns

These patterns compose well:

  • State Machine + Event Sourcing: record each state transition as an event. The state machine enforces valid transitions; the event log gives you full history. Good for order workflows where you need both correctness and auditability.
  • Feature Flags + anything: use Pennant to gate access to new aggregates or state machine variants during a migration.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Laravel Advanced Concepts AI skill do?

Advanced Laravel architectural patterns: Feature Flags, State Machines, and Event Sourcing. Use this skill whenever a user asks about: toggling features for users/groups, gradual rollouts, A/B testing, beta access (→ Feature Flags); modeling workflows like order status, subscription lifecycle, booking states, anything with defined transitions (→ State Machines); financial ledgers, credit/wallet systems, audit trails, undo history, GDPR-compliant data deletion, analytics replay (→ Event Sourcing). Also trigger when users mention spatie/laravel-model-states, Laravel Pennant, spatie/laravel-ev...

Why use Laravel Advanced Concepts on TypingMind?

Because you install it once and use it with any model. Laravel Advanced Concepts is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Laravel Advanced Concepts in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/peterfox/agent-skills/tree/main/laravel-advanced-concepts. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Laravel Advanced Concepts?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Laravel Advanced Concepts?

As many as you like. As long as a model supports skills, you can use Laravel Advanced Concepts with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Laravel Advanced Concepts AI skill free?

Yes. It is published on GitHub by peterfox under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇