solution-template

Generate or refactor LeetCode Python solution files in this repo. Use for standard Solution-class problems and design problems that must keep the original judged class name.

russhustle/leetpattern1 installsMITSynced Aug 26

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI

Agent Skills format with YAML frontmatter. Claude Code reads it as-is.

---
name: "solution-template"
description: "Generate or refactor LeetCode Python solution files in this repo. Use for standard Solution-class problems and design problems that must keep the original judged class name."
license: "MIT"
---

## Shape

- Files live in `leetpattern/python/{range}/{number}_{name}.py`.
- Use `Solution` for normal algorithm problems.
- For design problems, keep the original LeetCode class name and API exactly
  (`KthLargest`, `LRUCache`, `MedianFinder`, etc.). Do not wrap it in
  `Solution`.
- Put pytest-style inline tests at the bottom.

## Algorithm Skeleton

```python
class Solution:
    def methodName(self, args) -> ReturnType:
        """Approach Name: O(?) time, O(?) space.
        Key insight.
        """
        ...


def test_method_name():
    s = Solution()
    for fn in (s.methodName,):
        assert fn(case) == expected
```

## Design Skeleton

```python
class OriginalClassName:
    def __init__(self, args):
        """Setup Approach: O(?) time, O(?) space.
        Key state invariant.
        """
        ...

    def requiredMethod(self, args) -> ReturnType:
        """Operation Approach: O(?) time, O(?) space.
        Key update/query invariant.
        """
        ...


def test_original_class_name():
    obj = OriginalClassName(init_args)
    assert obj.requiredMethod(case) == expected
```

## Rules

1. Put the optimal approach first.
2. Use camelCase names matching LeetCode. Alternative algorithm methods may add a
   suffix such as `Sort`, `BF`, or `DP`.
3. Add docstrings to public solution methods. For design problems, document
   `__init__` and judged public operations.
4. Include at least 3 useful test cases, including an edge case.
5. Use only `test_` functions: no module headers, `print()`, or `if __name__`
   blocks.
6. Keep code minimal and lines at 90 characters or less.

More Refactoring skills

← All Refactoring skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY