state-machines
Skill0 starsChanged 3 months agoMITView on GitHub
状态机实战:订单状态、工作流引擎、游戏AI、FSM模式.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- waynesutton/convexskillstheir own version, first seen Nov 15, 2026
- waynesutton/builder-skillstheir own version, first seen Nov 15, 2026
- lbdremy/phaxtheir own version, first seen Oct 20, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- waynesutton/builder-skills★ 404same name
- waynesutton/convexskills★ 404same name
- lbdremy/phax★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository219 other files it gives its agents.
- agent-doctrineSkill
- agent-evaluation-frameworkSkill
- agent-visualization-flintSkill
- hermes-agentSkill
- bailian-cliSkill
- edge-browser-automationSkill
- computer-useSkill
- jupyter-live-kernelSkill
- backup-strategiesSkill
- browser-automationSkill
- chinese-ai-free-apiSkill
- cicd-pipeline-templatesSkill
- copybaraSkill
- devops-toolkitSkill
- email-deliverabilitySkill
- monitoring-observabilitySkill
- obsidian-maintenanceSkill
- obsidian-troubleshootingSkill
- openclaw-windowsSkill
- openclaw-workerSkill
- webhook-subscriptionsSkill
- windows-dev-environmentSkill
- windows-masterSkill
- zero-downtime-deploySkill
- codebase-inspectionSkill
- github-workflowSkill
- adaptive-communicationSkill
- agent-cost-dashboardSkill
- agent-evolutionSkill
- agent-governanceSkill
- agent-osSkill
- context-efficient-toolsSkill
- context-loss-awarenessSkill
- creative-synthesisSkill
- hermes-desktop-pluginsSkill
- emotional-intelligenceSkill
- graph-engineering-workflowSkill
- hermes-maintenanceSkill
- hermes-voiceSkill
- hermes-hygieneSkill
- identity-coreSkill
- income-loopSkill
- master-synthesisSkill
- meta-cognitionSkill
- reasoning-engineSkill
- self-preservationSkill
- teaching-abilitySkill
- temporal-awarenessSkill
- hermes-themesSkill
- thinking-visualizationSkill
- user-modelingSkill
- voice-full-restoreSkill
- knowledge-graph-traversalSkill
- mcp-browser-canvasSkill
- free-api-gatewaySkill
- native-mcpSkill
- web-reverse-apiSkill
- ai-edaSkill
- huggingface-hubSkill
- industrial-ai-siemens-mcpSkill
- The first 60 shown.
The file
Files
状态机实战
为什么用状态机
不用状态机:
if order.status == "pending":
if payment_ok:
order.status = "paid"
elif cancelled:
order.status = "cancelled"
elif order.status == "paid":
if shipped:
order.status = "shipped"
# 状态越多越乱,漏掉转换就出 bug
用状态机:
每个状态只有合法的转换路径
非法转换自动拒绝
代码清晰,不容易出 bugPython 实现
from enum import Enum
from dataclasses import dataclass
class State(Enum):
PENDING = "pending"
PAID = "paid"
SHIPPED = "shipped"
DELIVERED = "delivered"
CANCELLED = "cancelled"
# 定义合法转换
TRANSITIONS = {
State.PENDING: [State.PAID, State.CANCELLED],
State.PAID: [State.SHIPPED, State.CANCELLED],
State.SHIPPED: [State.DELIVERED],
}
class Order:
def __init__(self):
self.state = State.PENDING
def transition(self, new_state):
if new_state in TRANSITIONS.get(self.state, []):
self.state = new_state
return True
raise ValueError(f"不能从 {self.state} 转换到 {new_state}")
order = Order()
order.transition(State.PAID) # ✓
order.transition(State.SHIPPED) # ✓
order.transition(State.PENDING) # ✗ 不允许回退!使用 transitions 库
from transitions import Machine
class Order:
states = ['pending', 'paid', 'shipped', 'delivered', 'cancelled']
def __init__(self):
self.machine = Machine(model=self, states=Order.states, initial='pending')
self.machine.add_transition('pay', 'pending', 'paid')
self.machine.add_transition('ship', 'paid', 'shipped')
self.machine.add_transition('deliver', 'shipped', 'delivered')
self.machine.add_transition('cancel', ['pending', 'paid'], 'cancelled')
order = Order()
order.pay() # → paid
order.ship() # → shipped
order.cancel() # → 报错!shipped 状态不能 cancel状态机应用场景
1. 订单系统:pending→paid→shipped→delivered
2. 用户认证:logged_out→logging_in→logged_in→expired
3. 任务调度:queued→running→completed/failed
4. AI Agent:thinking→acting→observing→done
5. 游戏AI:idle→patrol→chase→attack→retreat
6. 爬虫:idle→fetching→parsing→storingagent-execution-engine 中的状态机
Agent 任务执行也是状态机:
queued → planning → executing → verifying → done
↘ failed → retry → executingDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

