mapcoder-code
Scannednpx machina-cli add skill NewJerseyStyle/plugin-map-coder/mapcoder-code --openclawMapCoder Coding Agent Skill
You are the Coding Agent in the MapCoder pipeline. Your task is to translate algorithmic plans into working, tested code.
Input
Parse $ARGUMENTS for:
--lang <language>: Target language (default: Python)--sandbox: Use sandbox execution- Problem description and/or algorithmic plan
Task
- Implement the solution following the provided plan
- Create test cases from sample inputs
- Execute and validate the code
- Report results
Implementation Process
Step 1: Code Generation
Write clean, idiomatic code in the target language:
# For Python
def solution(params):
"""
Brief description of the approach.
Time: O(...)
Space: O(...)
"""
# Implementation following the plan
pass
Step 2: Test Harness
Create a test file that:
- Includes the solution code
- Defines test cases from sample inputs
- Runs all tests and reports results
# test_solution.py
def test_example_1():
assert solution(input1) == expected1
def test_example_2():
assert solution(input2) == expected2
def test_edge_cases():
# Empty input, single element, etc.
pass
if __name__ == "__main__":
# Run all tests
test_example_1()
test_example_2()
test_edge_cases()
print("All tests passed!")
Step 3: Execution
Direct execution (default):
python test_solution.py
Sandbox execution (if --sandbox flag):
./scripts/sandbox-runner.sh python test_solution.py
Step 4: Report Results
## Code Implementation
**Language**: [language]
**Status**: [Passed/Failed]
### Solution Code
```[language]
[code]
Test Results
[execution output]
Issues Found (if any)
- [Issue 1]
- [Issue 2]
## Language-Specific Guidelines
### Python
- Use type hints for function signatures
- Follow PEP 8 style
- Use list comprehensions where appropriate
- Handle edge cases with early returns
### JavaScript
- Use modern ES6+ syntax
- Prefer const/let over var
- Use arrow functions for callbacks
- Add JSDoc comments
### Rust
- Use proper error handling with Result/Option
- Follow Rust naming conventions
- Include appropriate derive macros
- Write idiomatic iterator chains
### Go
- Follow Go naming conventions
- Use proper error handling
- Keep functions focused and small
- Use slices appropriately
### Java
- Use proper class structure
- Follow Java naming conventions
- Handle exceptions appropriately
- Use generics where applicable
## Quality Checklist
Before reporting success, verify:
- [ ] Code compiles/parses without errors
- [ ] All sample test cases pass
- [ ] Edge cases are handled
- [ ] Code follows the plan's algorithm
- [ ] Variable names are meaningful
- [ ] No hardcoded test-specific values
## Error Handling
If tests fail:
1. Capture the full error output
2. Identify which test case failed
3. Note the expected vs actual output
4. Pass this information to the Debugging Agent
Source
git clone https://github.com/NewJerseyStyle/plugin-map-coder/blob/main/skills/mapcoder-code/SKILL.mdView on GitHub Overview
The MapCoder mapcoder-code skill translates algorithmic plans into working, tested code. It automates the end-to-end workflow from plan to implementation, including a test harness and execution. It supports language selection via --lang and optional sandbox mode to ensure safe testing within the MapCoder pipeline.
How This Skill Works
The skill parses ARGUMENTS to determine the target language (default Python) and whether sandbox execution is requested. It then generates clean, idiomatic code following the provided plan, creates a test harness with sample inputs, and runs the tests either directly or in a sandbox, reporting results back with status and details.
When to Use It
- You have a problem description or algorithmic plan and need a working reference solution in code.
- You want to automatically generate tests from sample inputs and cover edge cases.
- You need multi-language output and want to switch languages with --lang <language>.
- You require safe, sandboxed execution for potentially unsafe or untrusted code.
- You are integrating with the MapCoder pipeline and want end-to-end codegen, testing, and reporting.
Quick Start
- Step 1: Generate idiomatic code in the target language from the plan.
- Step 2: Create test cases from sample inputs and add edge cases in a test file.
- Step 3: Run tests directly or via sandbox and review the reported results.
Best Practices
- Start with an idiomatic, language-specific template and add the plan-based logic.
- Include type hints (where applicable) and follow language-specific style guides.
- Create test cases from samples and add representative edge cases.
- Keep solution code modular, well-documented, and easy to debug.
- Verify tests via direct run or sandbox and capture clear results for reporting.
Example Use Cases
- Generate a Python LeetCode-style solution from a binary-search plan, with a corresponding test file and execution results.
- Produce a JavaScript implementation for an array-manipulation plan, along with tests and a sandbox-runner.
- Render a Rust solution from a graph-traversal plan, including Result-based error handling and tests.
- Create a Go implementation for a shortest-path plan with unit tests and sandbox execution.
- Automate a Java solution from a dynamic-programming plan, with a labeled test suite and results output.