better-leetcode

Optimize and refactor LeetCode solutions to be more elegant, readable, and idiomatic. Use when the user provides code from a LeetCode problem and wants to improve code quality, simplify logic, enhance variable naming, or make the solution more concise and maintainable. Also use when the user asks to "optimize", "refactor", "improve", or "clean up" LeetCode code.

16 stars

Best use case

better-leetcode is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Optimize and refactor LeetCode solutions to be more elegant, readable, and idiomatic. Use when the user provides code from a LeetCode problem and wants to improve code quality, simplify logic, enhance variable naming, or make the solution more concise and maintainable. Also use when the user asks to "optimize", "refactor", "improve", or "clean up" LeetCode code.

Teams using better-leetcode should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/better-leetcode/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/data-ai/better-leetcode/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/better-leetcode/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How better-leetcode Compares

Feature / Agentbetter-leetcodeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Optimize and refactor LeetCode solutions to be more elegant, readable, and idiomatic. Use when the user provides code from a LeetCode problem and wants to improve code quality, simplify logic, enhance variable naming, or make the solution more concise and maintainable. Also use when the user asks to "optimize", "refactor", "improve", or "clean up" LeetCode code.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Better LeetCode

Refactor LeetCode solutions to follow clean code principles: clear logic, intuitive variable names, minimal comments, and idiomatic patterns.

## Core Principles

1. **Clear over clever**: Prefer readable solutions that are easy to understand at first glance
2. **Minimal comments**: Code should be self-documenting through good naming and clear structure
3. **Idiomatic patterns**: Use well-known algorithms and data structures with their standard implementations
4. **Concise variable names**: Use short but meaningful names that follow common conventions

## Refactoring Guidelines

### Variable Naming

Use standard, memorable variable names for common patterns:

- **Pointers**: `slow`, `fast`, `left`, `right`, `i`, `j`, `k`
- **Lists/Arrays**: `nums`, `arr`, `res`, `ans`
- **Trees**: `root`, `node`, `left`, `right`
- **Graphs**: `graph`, `node`, `visited`, `adj`
- **Strings**: `s`, `t`, `word`, `pattern`
- **Counters**: `count`, `cnt`, `freq`
- **Results**: `res`, `ans`, `result`

### Code Structure

**Do:**
- Keep functions focused and simple
- Use early returns to reduce nesting
- Prefer while loops for unclear iteration counts
- Use for loops with range for known iterations
- Initialize variables close to usage

**Avoid:**
- Excessive comments explaining obvious logic
- Overly complex one-liners that sacrifice readability
- Unnecessary temporary variables
- Deep nesting (>3 levels)

### Common Patterns

**Two Pointers:**
```python
slow = fast = head
while fast and fast.next:
    fast = fast.next.next
    slow = slow.next
```

**Sliding Window:**
```python
left = 0
for right in range(len(s)):
    # expand window
    while condition:
        # shrink window
        left += 1
```

**Binary Search:**
```python
left, right = 0, len(nums) - 1
while left <= right:
    mid = (left + right) // 2
    if nums[mid] == target:
        return mid
    elif nums[mid] < target:
        left = mid + 1
    else:
        right = mid - 1
```

**DFS (Tree):**
```python
def dfs(node):
    if not node:
        return
    # process node
    dfs(node.left)
    dfs(node.right)
```

**BFS:**
```python
from collections import deque

queue = deque([start])
while queue:
    node = queue.popleft()
    # process node
    if condition:
        queue.append(next_node)
```

## Optimization Process

When refactoring code:

1. **Analyze**: Identify the algorithm/pattern being used
2. **Simplify**: Remove unnecessary complexity and redundancy
3. **Rename**: Apply standard variable naming conventions
4. **Structure**: Organize code for maximum readability
5. **Verify**: Ensure logic correctness is maintained

Focus on readability and maintainability over micro-optimizations unless performance is explicitly required.

Related Skills

tool-better-auth

16
from diegosouzapw/awesome-omni-skill

Use when implementing authentication with Better Auth in a TypeScript/Next.js app (session strategy, providers, cookies, CSRF, redirects, middleware, and security best practices).

better-auth

16
from diegosouzapw/awesome-omni-skill

Implement authentication and authorization with Better Auth - a framework-agnostic TypeScript authentication framework. Features include email/password authentication with verification, OAuth providers (Google, GitHub, Discord, etc.), two-factor authentication (TOTP, SMS), passkeys/WebAuthn support, session management, role-based access control (RBAC), rate limiting, and database adapters. Use when adding authentication to applications, implementing OAuth flows, setting up 2FA/MFA, managing user sessions, configuring authorization rules, or building secure authentication systems for web applications.

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development

Prompt Engineering Skill

16
from diegosouzapw/awesome-omni-skill

Craft effective prompts that get the best results from language models.

prompt-engineering-openai-api-f7c24501

16
from diegosouzapw/awesome-omni-skill

Log in [Sign up](https://platform.openai.com/signup)

prompt-engineer-llm

16
from diegosouzapw/awesome-omni-skill

World-class expert in prompt engineering, LLM fine-tuning, RAG systems, and AI/ML workflows. Use when crafting prompts, designing AI agents, building knowledge bases, implementing retrieval systems, or optimizing LLM performance at production scale.

project-spec

16
from diegosouzapw/awesome-omni-skill

Create a project spec for AI agents to work from autonomously.

project-orchestrator

16
from diegosouzapw/awesome-omni-skill

Master coordinator for complete project setup from ideation to ready-to-code. Manages workflow through ideation, research, tech stack selection, documentation, and project initialization to deliver working projects in minutes.

project-domain

16
from diegosouzapw/awesome-omni-skill

Capture subject matter expertise and domain knowledge that will inform all product decisions - the ubiquitous language, domain rules, and principles from the field

project-bootstrap

16
from diegosouzapw/awesome-omni-skill

Bootstrap a new or existing project with stack detection and project.json generation. Use when adding a new project, setting up agent system, or generating project manifest. Triggers on: add project, new project, bootstrap project, setup project, detect stack.

projecoes-read-models

16
from diegosouzapw/awesome-omni-skill

Use para criar projeções como 9BOX, dashboards e visões de leitura otimizadas para decisão.

product-agent

16
from diegosouzapw/awesome-omni-skill

Discover and validate product ideas, analyze markets, scope MVPs, and optimize app store presence for iOS/macOS apps. Use when user asks to discover, validate, assess, scope, or analyze product ideas, market opportunities, or when they mention "product agent", "app idea validation", "should I build this", "MVP", "market analysis", or "ASO".