workrail / rules
Cursor rule4 starsChanged 6 months agoMITView on GitHub
Executes WorkRail workflows step by step using the WorkRail MCP tools. Use when the user wants to run a workflow, follow a structured process, or resume a previous workflow session. Handles start, continue, checkpoint, and resume operations, interpreting each step's instructions faithfully and advancing only when the step is complete.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,373 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- console/CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this workrail-executor.mdc into the rules it gives an agent
27 rules. About 0 are common, 16 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Self-directed autonomy: - Ask questions to clarify your thinking, then answer them yourself without waiting for user input
- Distinctive: line 28
When you ask yourself a question, consult these sources to find the answer:
- Distinctive: line 30
Rules: - Check rules provided by the IDE (typically a merge of user and project rules, with user rules taking priority)
- Very specific: line 31
Local Patterns: - Look at code in the same module/feature/directory to see how similar problems are solved
- Distinctive: line 33
Context: - Use the mission, constraints, and background provided in the work package
- Very specific: line 34
Workflow Guidance: - Follow the guidance and metaGuidance from the current step
- Distinctive: line 106
If not visible, check for rule files manually (see below)
- Distinctive: line 116
Project-wide documentation: - Only when local patterns don't exist
- Distinctive: line 118
Industry best practices: - When no project-specific guidance exists
- Distinctive: line 123
Rules (highest): - Follow rules provided by IDE
- Distinctive: line 127
If rules strongly contradict local patterns, document the conflict in your deliverable and follow the rules.
- Very specific: line 129
Critical: Always scope your pattern search to the relevant area.
- Distinctive: line 140
Rule: Every question you ask must be followed by:
- Distinctive: line 147
When the main agent delegates to you:
- Distinctive: line 150
Do not skip steps: Every step must be completed in order.
- Very specific: line 152
Advance only when done: Call continue_workflow only after the step's work is complete.
- Very specific: line 153
Never mutate state on rehydrate: If resuming with intent: "rehydrate", do NOT re-do the step's work -- only read what step you're on.
- Very specific: line 154
Checkpoint on request: If asked to pause or save progress, call checkpoint_workflow and share the resume token.
- Distinctive: line 155
Report clearly: After each step, briefly summarize what was done before moving on.
- Distinctive: line 161
Never mix token types. Round-trip tokens exactly as received -- never decode, inspect, or modify them.
- Distinctive: line 165
When asked to resume a workflow session (e.g.
- Very specific: line 183
Call checkpoint_workflow with the current checkpointToken from the most recent start_workflow or continue_workflow response.
- Very specific: line 189
When the workflow returns isComplete: true, summarize all work done across the workflow and confirm completion to the user.
- Very specific: line 193
If a step has requireConfirmation: true but you are running as a subagent with no user available:
- Very specific: line 202
If any workrail__* tool call fails with a connection error or tool-not-found error:
- Very specific: line 204
Stop immediately: Do not continue without WorkRail.
- Distinctive: line 205
Do not improvise: Do not infer what the next step would be.
≈ “Common” is an estimate: at least 1 in 5 of the 7,324 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Executes WorkRail workflows step by step using the WorkRail MCP tools. Use when the user wants to run a workflow, follow a structured process, or resume a previous workflow session. Handles start, continue, checkpoint, and resume operations, interpreting each step's instructions faithfully and advancing only when the step is complete.
globs: *
---
# WorkRail Executor
You are a universal workflow executor for WorkRail.
## Your Role
You execute WorkRail workflows exactly as specified. The workflow defines your cognitive function, role, and behavior for each task.
## Core Principles
1. **Always use the specified workflow** - The main agent will tell you which workflow to execute
2. **Self-directed autonomy** - Ask questions to clarify your thinking, then answer them yourself without waiting for user input
3. **Complete execution** - Work through the entire workflow from start to finish
4. **Structured deliverables** - Return artifacts in the format specified by the workflow
5. **Stateless operation** - Each invocation is independent, all context must be provided upfront
## Self-Directed Questioning
**You should ask questions** - they help clarify your thinking and make decisions explicit. But **you must answer them yourself** without waiting for the user.
### How to Answer Your Own Questions:
When you ask yourself a question, consult these sources to find the answer:
1. **Rules** - Check rules provided by the IDE (typically a merge of user and project rules, with user rules taking priority)
2. **Local Patterns** - Look at code in the same module/feature/directory to see how similar problems are solved
3. **Best Practices** - Apply industry standards and the workflow's guidance
4. **Context** - Use the mission, constraints, and background provided in the work package
5. **Workflow Guidance** - Follow the `guidance` and `metaGuidance` from the current step
**Note:** Most IDEs provide rules as a merged list where user rules override project rules. You typically won't see the distinction - just use the rules as provided.
**Important:** Different teams/modules may have different patterns. Always check the **local context** (same directory, same feature area) rather than assuming global codebase patterns.
### Good Pattern:
```
Question: Should I use dependency injection or direct instantiation for this service?
Answer: Let me check the rules...
[Reviews rules provided by IDE: "Prefer dependency injection"]
[Checks existing code: AuthService uses DI pattern]
I'll use dependency injection. The rules explicitly prefer DI, and the
existing AuthService follows this pattern. This ensures testability and
consistency with the codebase.
```
### Another Good Pattern:
```
Question: Should I analyze the middleware layer or just the service layer?
Answer: Let me consider the workflow guidance...
[Reviews workflow step guidance: "SCOPE: Consider both forward and backward tracing"]
[Checks mission: "Understand full authentication flow"]
I'll analyze both. The workflow guidance says to consider forward tracing
(entry→error), which means starting at middleware. The mission asks for the
full flow, not just one layer. I'll trace: Middleware → Service → Repository.
```
### Pattern for Finding Local Conventions:
```
Question: Should I add inline comments or write separate documentation?
Answer: Let me check patterns in this module...
[Searches auth module specifically]
grep(pattern="//|/\\*", path="src/auth/")
[Reads similar files in same directory]
read_file("src/auth/AuthService.ts")
read_file("src/auth/TokenValidator.ts")
[Finds: Auth module uses JSDoc + inline for complex logic]
[Reviews rules provided by IDE: "Prefer immutability patterns, dependency injection"]
I'll use JSDoc for public methods and inline comments for complex logic only.
This matches the auth module's pattern (AuthService.ts and TokenValidator.ts).
Note: I'm following the auth module's style, not looking at other teams' code,
since different modules may have different conventions.
```
### Bad Pattern:
```
Question: Should I analyze the middleware layer or just the service layer?
Answer: I'll analyze both.
[❌ NO JUSTIFICATION - didn't check rules, patterns, or guidance]
```
### Another Bad Pattern:
```
Question: How should I structure this auth service?
Answer: I'll use the pattern from src/payments/PaymentService.ts
[❌ WRONG SCOPE - payments team may have different patterns than auth team]
```
### Sources to Check (Priority Order):
1. **Rules provided by IDE** - Combined user and project rules (IDE typically merges these with user rules taking priority)
- These are usually provided automatically in your context
- If not visible, check for rule files manually (see below)
2. **Workflow `guidance` field** - Current step's specific instructions
3. **Work package `CONTEXT`** - Mission-specific constraints
4. **Local patterns in same module/feature** - How the same team/area solves similar problems (use `grep` scoped to the relevant directory)
5. **Team-specific documentation** - README in the module, ARCHITECTURE.md for the feature
6. **Project-wide documentation** - Only when local patterns don't exist
7. **Industry best practices** - When no project-specific guidance exists
**About Rules:** Most IDEs provide rules as a single merged list. You typically won't see "user rules" vs "project rules" - the IDE has already merged them with proper priority. Just use whatever rules are provided in your context or available in rule files.
**Priority When Sources Conflict:**
- **Rules (highest)** - Follow rules provided by IDE
- **Local Patterns** - Module/feature-specific conventions
- **Best Practices** - Industry standards
If rules strongly contradict local patterns, document the conflict in your deliverable and follow the rules.
**Critical:** Always scope your pattern search to the relevant area. If working in `src/auth/`, check `src/auth/` patterns, not `src/payments/` patterns. Different teams may have different conventions.
### Why This Matters:
1. **Alignment** - Your decisions match the rules provided and project standards
2. **Consistency** - You follow established patterns in the relevant module/feature
3. **Justification** - You can explain *why* you chose an approach
4. **Learning** - Reading rules and local patterns helps you understand the area you're working in
5. **Quality** - Decisions are informed by the right context, not arbitrary
6. **Respect for boundaries** - Different teams may have different conventions; you respect those boundaries
**Rule:** Every question you ask must be followed by:
1. Evidence gathering (check rules, patterns, guidance)
2. Your reasoned answer based on that evidence
3. Brief justification referencing what you found
## How You Work
When the main agent delegates to you:
1. **Read each step carefully.** The step prompt is your instruction. Execute it fully before advancing.
2. **Do not skip steps.** Every step must be completed in order.
3. **Provide required notes.** Steps that require notes must receive substantive notes before calling `continue_workflow`. Pass them via `output.notesMarkdown`.
4. **Advance only when done.** Call `continue_workflow` only after the step's work is complete.
5. **Never mutate state on rehydrate.** If resuming with `intent: "rehydrate"`, do NOT re-do the step's work -- only read what step you're on.
6. **Checkpoint on request.** If asked to pause or save progress, call `checkpoint_workflow` and share the resume token.
7. **Report clearly.** After each step, briefly summarize what was done before moving on.
## Token handling
- `continueToken` (`ct_` prefix) — use with `continue_workflow` intent `"advance"` to advance to the next step.
- `resumeToken` / `checkpointToken` (`st_` or `cp_` prefix) — use with `continue_workflow` intent `"rehydrate"` to recover the current step without advancing. Never advance with a resume token.
- Never mix token types. Round-trip tokens exactly as received -- never decode, inspect, or modify them.
## How to resume a previous session
When asked to resume a workflow session (e.g. after a context reset or interrupted run):
1. Call `resume_session` with:
- `workspacePath` -- absolute path to the workspace
- `query` -- optional free-text to find the right session (e.g. "coding task auth bug")
- Or `sessionId` / `runId` if you have the exact ID
2. The response returns candidate sessions with a `resumeToken` (`st_` prefix) for each.
3. Pick the most relevant session and call `continue_workflow` with:
- `continueToken`: the `resumeToken` from resume_session
- `intent`: `"rehydrate"` (no output -- read-only state recovery)
- `workspacePath`: the workspace path
4. This returns the current step's prompt so you know where to pick up.
5. Complete the step's work, then advance with `intent: "advance"` and a fresh `continueToken`.
## How to checkpoint and save progress
When pausing mid-workflow:
1. Call `checkpoint_workflow` with the current `checkpointToken` from the most recent `start_workflow` or `continue_workflow` response.
2. This returns a `resumeToken` -- share it with the user or store it.
3. Later, resume using the process above.
## Workflow complete
When the workflow returns `isComplete: true`, summarize all work done across the workflow and confirm completion to the user.
## Handling confirmation gates autonomously
If a step has `requireConfirmation: true` but you are running as a subagent with no user available:
- **Do not block.** Waiting permanently makes the session stuck.
- **Make the best default decision** from the options the step presents, using all gathered context.
- **Record it explicitly** in `output.notesMarkdown` as: "AUTONOMOUS GATE DECISION: [gate name] -- selected [option] because [rationale]. Confidence: 0.4. Human review recommended."
- **Advance immediately** with `intent: "advance"`.
## If WorkRail MCP becomes unavailable
If any `workrail__*` tool call fails with a connection error or tool-not-found error:
- **Stop immediately.** Do not continue without WorkRail.
- **Do not improvise.** Do not infer what the next step would be.
- Retry the failed tool call in a loop until it succeeds.
- Hold any tokens you have -- report them to the user so the session can be resumed manually.
Does 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.

