hailo-apps / rules
Cursor rule506 starsChanged 7 months agoMITView on GitHub
Skill: Plan-and-Execute Loop
We split this hl-plan-and-execute.mdc into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
Read the following files and return a structured context brief:
- Distinctive: line 135
Write the complete file content
- Distinctive: line 142
Read the current file content first
- Distinctive: line 145
Never remove existing functionality
- Distinctive: line 204
Read error output carefully
- Very specific: line 205
Check .hailo/memory/common_pitfalls.md
- Distinctive: line 206
Add a "Fix: <description>" todo item
- Distinctive: line 210
If still failing, try a different approach
- Distinctive: line 211
If STILL failing, document the blocker and ask the user
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 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: "Skill: Plan-and-Execute Loop"
alwaysApply: false
---
````instructions
# Skill: Plan-and-Execute Loop
> Execute complex tasks through a disciplined loop of planning, delegating, implementing, and gating — the core agentic workflow pattern for this repository.
## When to Use This Skill
- Building a new application (any archetype)
- Refactoring across multiple files
- Bug fixes that touch 3+ files
- Any task where the agent should "think before coding"
## The Loop
```
PLAN → DELEGATE → EXECUTE → GATE → (loop or advance)
```
---
## Step 1: Plan
### Read Context (Sub-Agent)
Spawn a context-loading sub-agent FIRST. This is the most important step.
```
runSubagent:
description: "Load task context"
prompt: |
Read the following files and return a structured context brief:
MEMORY (always):
- .hailo/memory/MEMORY.md
- .hailo/memory/common_pitfalls.md
DOMAIN (pick relevant):
- .hailo/memory/gen_ai_patterns.md ← for Gen AI apps
- .hailo/memory/pipeline_optimization.md ← for GStreamer apps
- .hailo/memory/camera_and_display.md ← for camera apps
- .hailo/memory/hailo_platform_api.md ← for direct HailoRT
SKILL (pick one):
- .hailo/skills/<relevant_skill>.md
REFERENCE CODE:
- <reference_app_main_file>
- <reference_app_supporting_files>
Return:
1. App archetype (pipeline/standalone/gen-ai)
2. Modules to reuse (with exact import paths)
3. Conventions to follow (top 5)
4. Known pitfalls for this task type
5. Key function signatures from reference code
```
### Create the Plan (Todo List)
After receiving the context brief, create a structured todo list:
```python
manage_todo_list([
# Phase 0
{"id": 1, "title": "Load context (sub-agent)", "status": "completed"},
# Phase 1: Planning & Registration
{"id": 2, "title": "Register app in defines.py", "status": "not-started"},
{"id": 3, "title": "Create directory + __init__.py", "status": "not-started"},
{"id": 4, "title": "GATE: Verify directory exists", "status": "not-started"},
# Phase 2: Implementation
{"id": 5, "title": "Implement <module_a>", "status": "not-started"},
{"id": 6, "title": "Implement <module_b>", "status": "not-started"},
{"id": 7, "title": "Implement <main_module>", "status": "not-started"},
{"id": 8, "title": "GATE: Validate all imports", "status": "not-started"},
# Phase 3: Validation
{"id": 9, "title": "Run --help validation", "status": "not-started"},
{"id": 10, "title": "Check lint errors", "status": "not-started"},
{"id": 11, "title": "GATE: Full validation pass", "status": "not-started"},
# Phase 4: Documentation
{"id": 12, "title": "Write README.md", "status": "not-started"},
{"id": 13, "title": "Update memory if needed", "status": "not-started"},
{"id": 14, "title": "GATE: Final review", "status": "not-started"},
])
```
**Key pattern**: Include explicit `GATE:` items in the todo list. These are checkpoints, not tasks.
---
## Step 2: Delegate
### Identify Parallelizable Work
Within each phase, find tasks that have NO dependencies on each other:
```
Phase 2 dependency analysis:
- event_tracker.py → depends on nothing (pure logic)
- my_vlm_app.py → imports from event_tracker.py
- README.md → describes my_vlm_app.py
Therefore:
- event_tracker.py can be a sub-agent (independent)
- my_vlm_app.py must wait for event_tracker.py
- README.md can be a sub-agent (after implementation done)
```
### Launch Independent Sub-Agents
```
# Parallel sub-agents for independent modules
runSubagent A: "Build event_tracker.py — [full spec with context]"
runSubagent B: "Search codebase for signal handling patterns — return examples"
```
Wait for results, then build dependent modules in the main agent.
---
## Step 3: Execute
### Implementation Sequence
```
For each file to create:
1. Write the complete file content
2. Include ALL imports at the top
3. Include docstrings on every class and public function
4. Include type hints on all function signatures
5. Handle errors with try/except and logging
For each file to modify:
1. Read the current file content first
2. Make minimal, targeted changes
3. Preserve existing formatting and style
4. Never remove existing functionality
```
### Code Quality During Execution
While writing each file, apply these inline checks:
```python
# ✓ Absolute import
from hailo_apps.python.core.common.hailo_logger import get_logger
# ✗ Relative import — NEVER
from ...core.common.hailo_logger import get_logger
# ✓ Logger initialization
logger = get_logger(__name__)
# ✗ Print statements — NEVER in production code
print("Debug info")
# ✓ HEF resolution
hef_path = resolve_hef_path(model_path, APP_NAME, arch)
# ✗ Hardcoded path — NEVER
hef_path = "/home/user/models/model.hef"
```
---
## Step 4: Gate
### Gate Check Execution
Run these commands at each phase boundary:
```bash
# Phase 1 Gate: Structure exists
ls -la hailo_apps/python/gen_ai_apps/<app_name>/
# Expect: __init__.py and any stub files
# Phase 2 Gate: Code is importable
python3 -c "
from hailo_apps.python.gen_ai_apps.<app_name>.<main_module> import <MainClass>
print('Import OK')
"
# Expect: "Import OK"
# Phase 3 Gate: CLI works
python3 -m hailo_apps.python.gen_ai_apps.<app_name>.<main_module> --help
# Expect: Help text with all expected arguments
# Phase 4 Gate: Everything is documented
test -f hailo_apps/python/gen_ai_apps/<app_name>/README.md && echo "README OK"
```
### Gate Failure Recovery
```
IF gate fails:
1. Read error output carefully
2. Check .hailo/memory/common_pitfalls.md
3. Add a "Fix: <description>" todo item
4. Mark the gate todo as "not-started" (will re-check after fix)
5. Implement the fix
6. Re-run the gate
7. If still failing, try a different approach
8. If STILL failing, document the blocker and ask the user
```
---
## Complete Example: Building a VLM Monitor
```
Phase 0: Context
├── runSubagent: Load VLM + monitoring context (returns brief)
└── Create todo list with all phases
Phase 1: Registration (main agent)
├── Add MY_VLM_APP to defines.py
├── Create my_vlm_app/__init__.py
└── GATE: grep defines.py for MY_VLM_APP ✓
Phase 2: Implementation
├── runSubagent: Build event_tracker.py (independent)
├── Main agent: Build my_vlm_app.py (uses Backend + EventTracker)
└── GATE: python3 -c "from ...my_vlm_app import MyVlmApp" ✓
Phase 3: Validation
├── Terminal: python3 -m ...my_vlm_app --help
├── get_errors on all .py files
├── Convention checklist (imports, logger, paths)
└── GATE: All checks pass ✓
Phase 4: Documentation
├── runSubagent: Write README.md with usage examples
├── Update memory if something new was learned
└── GATE: README exists, re-run import validation ✓
DONE: Mark all todos complete, report deliverables to user
```
---
## Adapting the Loop for Different Scales
### Small Task (< 3 files)
Skip sub-agents. Run the loop in main agent only. Still use todo list and gates.
### Medium Task (3-6 files)
Use 1-2 sub-agents for independent modules. Full 4-phase loop.
### Large Task (7+ files or cross-cutting)
Use 3+ sub-agents. Consider splitting into multiple PRs. Add a "Phase 2.5: Integration sub-phase" where you wire modules together before the full validation.
````
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 3,978 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 repository65 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/core-framework.mdcCursor rule
- .cursor/rules/gen-ai-apps.mdcCursor rule
- .cursor/rules/hailo-global.mdcCursor rule
- .cursor/rules/hl-build-agent-app.mdcCursor rule
- .cursor/rules/hl-build-llm-app.mdcCursor rule
- .cursor/rules/hl-build-pipeline-app.mdcCursor rule
- .cursor/rules/hl-build-standalone-app.mdcCursor rule
- .cursor/rules/hl-build-vlm-app.mdcCursor rule
- .cursor/rules/hl-build-voice-app.mdcCursor rule
- .cursor/rules/hl-camera.mdcCursor rule
- .cursor/rules/hl-event-detection.mdcCursor rule
- .cursor/rules/hl-model-management.mdcCursor rule
- .cursor/rules/hl-monitoring.mdcCursor rule
- .cursor/rules/hl-validate.mdcCursor rule
- .cursor/rules/inst-agent-protocols.mdcCursor rule
- .cursor/rules/inst-architecture.mdcCursor rule
- .cursor/rules/inst-coding-standards.mdcCursor rule
- .cursor/rules/inst-gen-ai-development.mdcCursor rule
- .cursor/rules/inst-gstreamer-pipelines.mdcCursor rule
- .cursor/rules/inst-orchestration.mdcCursor rule
- .cursor/rules/inst-testing-patterns.mdcCursor rule
- .cursor/rules/memory-camera_and_display.mdcCursor rule
- .cursor/rules/memory-common_pitfalls.mdcCursor rule
- .cursor/rules/memory-gen_ai_patterns.mdcCursor rule
- .cursor/rules/memory-hailo_platform_api.mdcCursor rule
- .cursor/rules/memory-MEMORY.mdcCursor rule
- .cursor/rules/memory-pipeline_optimization.mdcCursor rule
- .cursor/rules/pipeline-apps.mdcCursor rule
- .cursor/rules/prompt-new-agent-tool.mdcCursor rule
- .cursor/rules/prompt-new-llm-app.mdcCursor rule
- .cursor/rules/prompt-new-pipeline-app.mdcCursor rule
- .cursor/rules/prompt-new-pose-game.mdcCursor rule
- .cursor/rules/prompt-new-standalone-app.mdcCursor rule
- .cursor/rules/prompt-new-vlm-variant.mdcCursor rule
- .cursor/rules/prompt-new-voice-app.mdcCursor rule
- .cursor/rules/prompt-orchestrated-build.mdcCursor rule
- .cursor/rules/standalone-apps.mdcCursor rule
- .cursor/rules/tests.mdcCursor rule
- .cursor/rules/toolset-core-framework-api.mdcCursor rule
- .cursor/rules/toolset-gen-ai-utilities.mdcCursor rule
- .cursor/rules/toolset-gstreamer-elements.mdcCursor rule
- .cursor/rules/toolset-hailort-api.mdcCursor rule
- .cursor/rules/toolset-pose-keypoints.mdcCursor rule
- .cursor/rules/toolset-vlm-backend-api.mdcCursor rule
- .cursor/rules/toolset-yolo-coco-classes.mdcCursor rule
- hl-build-agent-appSkill
- hl-build-llm-appSkill
- hl-build-pipeline-appSkill
- hl-build-standalone-appSkill
- hl-build-vlm-appSkill
- hl-build-voice-appSkill
- hl-cameraSkill
- hl-event-detectionSkill
- hl-model-managementSkill
- hl-monitoringSkill
- hl-plan-and-executeSkill
- hl-validateSkill
- hl-build-agent-appSkill
- The first 60 shown.
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.

