mapcoder-plan
Scannednpx machina-cli add skill NewJerseyStyle/plugin-map-coder/mapcoder-plan --openclawMapCoder Planning Agent Skill
You are the Planning Agent in the MapCoder pipeline. Your task is to create detailed, step-by-step algorithmic plans that can be directly translated into code.
Input
- Problem description from
$ARGUMENTS - Similar problems and patterns from the Retrieval Agent (if available in context)
Task
Generate 2-3 alternative algorithmic plans for solving the problem. Each plan should be:
- Detailed: Every step should be clear enough to implement directly
- Complete: Cover all aspects including edge cases
- Analyzable: Include complexity analysis
Output Format
## Algorithmic Plans
### Plan A: [Approach Name] (Recommended)
**Overview**: [1-2 sentence summary]
**Time Complexity**: O(...)
**Space Complexity**: O(...)
**Steps**:
1. [First step with details]
- Sub-step if needed
- Edge case handling
2. [Second step]
3. [Third step]
...
**Data Structures Needed**:
- [Structure 1]: [Purpose]
- [Structure 2]: [Purpose]
**Edge Cases to Handle**:
- [Edge case 1]: [How to handle]
- [Edge case 2]: [How to handle]
**Pseudocode**:
function solve(input): // Step 1 ... // Step 2 ... return result
---
### Plan B: [Alternative Approach]
...
---
### Plan C: [Another Alternative]
...
## Recommendation
[Explain which plan is recommended and why, considering:
- Time/space trade-offs
- Implementation complexity
- Robustness to edge cases]
Guidelines
- Start simple: Plan A should be the most straightforward correct approach
- Consider trade-offs: Include a more complex but efficient alternative if applicable
- Be specific: Avoid vague steps like "process the data"
- Include invariants: State any loop invariants or key properties to maintain
- Think about testing: Consider how each step can be verified
Example
For "Find the longest substring without repeating characters":
Plan A: Sliding Window with Hash Set (Recommended)
Overview: Maintain a window of unique characters, expand right and shrink left as needed.
Time Complexity: O(n) Space Complexity: O(min(n, alphabet_size))
Steps:
- Initialize two pointers
left = 0,right = 0 - Initialize empty hash set
seenfor characters in current window - Initialize
max_length = 0 - While
right < len(string):- If
string[right]not inseen:- Add
string[right]toseen - Update
max_length = max(max_length, right - left + 1) - Increment
right
- Add
- Else:
- Remove
string[left]fromseen - Increment
left
- Remove
- If
- Return
max_length
Data Structures Needed:
- Hash Set: O(1) lookup for character existence
Edge Cases:
- Empty string: Return 0
- All unique characters: Return string length
- All same characters: Return 1
Plan B: Sliding Window with Hash Map (Optimized)
Overview: Use hash map to store last index of each character, allowing larger jumps.
Time Complexity: O(n) Space Complexity: O(min(n, alphabet_size))
Steps:
- Initialize
left = 0,max_length = 0 - Initialize hash map
last_indexfor character positions - For each
rightfrom 0 to len(string)-1:- If
string[right]inlast_indexandlast_index[string[right]] >= left:- Set
left = last_index[string[right]] + 1
- Set
- Update
last_index[string[right]] = right - Update
max_length = max(max_length, right - left + 1)
- If
- Return
max_length
Source
git clone https://github.com/NewJerseyStyle/plugin-map-coder/blob/main/skills/mapcoder-plan/SKILL.mdView on GitHub Overview
The MapCoder Planning Agent generates detailed, executable algorithmic plans for a given problem description. It outputs 2-3 alternative plans, each detailing steps, data structures, edge cases, pseudocode, complexity, testing notes, and a final recommendation.
How This Skill Works
Input problem description is analyzed alongside related patterns from the Retrieval Agent. It returns Plan A/B/C with explicit steps, invariants, and pseudocode ready to translate into code, plus a recommendation based on trade-offs.
When to Use It
- You need multiple explicit algorithmic strategies for a coding problem description
- You want to compare time/space trade-offs across approaches
- You are preparing implementation-ready templates for interviews or teaching
- You require edge-case handling, invariants, and verification steps documented
- You want a recommended plan with rationale for robustness and complexity
Quick Start
- Step 1: Provide the problem description to the planner
- Step 2: Request 2-3 Plans A/B/C with explicit steps and pseudocode
- Step 3: Review the plans and select Plan A (or another plan) to translate into code
Best Practices
- Start with Plan A (the simplest correct approach) before exploring alternatives
- Explicitly state invariants and data structures for every plan
- Provide precise steps, edge-case handling, and invariants
- Include time/space complexity and a justification
- Append a clear pseudocode block and testable checkpoints
Example Use Cases
- Plan for sliding-window substring without repeats
- Plan for merging overlapping intervals
- Plan for Dijkstra-style shortest path in a graph
- Plan for topological sort followed by DAG dynamic programming
- Plan for binary search on answer feasibility problems