title: Implement Function from Spec

description: Generate a single, well-tested function from a precise specification.

content:
Implement a {{language}} function named `{{name}}` that satisfies this specification:

{{spec}}

Requirements:
- Handle all edge cases explicitly (empty input, nulls, boundaries, overflow).
- No external dependencies unless I name them.
- Add a short docstring describing parameters, return value, and thrown errors.
- Follow idiomatic style and naming for {{language}}.

After the implementation, list the edge cases you handled and any assumptions you made.

language

description: Programming language

name

description: Function name

spec

description: What the function must do


title: Add Feature to Existing Code

description: Extend a codebase with a new feature while preserving existing behavior and conventions.

content:
I want to add the following feature: {{feature}}

Before writing code:
1. Identify the files and functions that must change, and explain why.
2. Describe how you'll keep existing behavior intact (and which tests prove it).
3. Match the project's existing patterns, naming, and error-handling style.

Then implement the change as a minimal, reviewable diff. Call out any place where the existing code made you choose between two reasonable approaches.

feature

description: The feature to add


title: Explain This Code

description: Get a clear, layered explanation of an unfamiliar piece of code.

content:
Explain the following code:

```
{{code}}
```

Structure your answer as:
1. One sentence: what it does overall.
2. A step-by-step walk-through of the control flow.
3. Any non-obvious details — performance characteristics, side effects, edge cases, or subtle bugs.
4. What a caller needs to know to use it correctly.

Assume I'm a competent engineer new to this specific code.

code

description: The code to explain


title: Convert Pseudocode to Code

description: Translate an algorithm or pseudocode into working, idiomatic code.

content:
Translate the following pseudocode/algorithm into idiomatic {{language}}:

{{pseudocode}}

- Preserve the algorithm's complexity; note the Big-O of the result.
- Use clear names; don't leave single-letter variables unless conventional.
- Add input validation where a real caller could pass bad data.
- Include a couple of usage examples.

language

description: Target language

pseudocode

description: The algorithm or pseudocode


title: Implement an API Client

description: Write a typed client for a REST or RPC API from its docs.

content:
Write a {{language}} client for this API:

{{api_description}}

Requirements:
- Strong types for every request and response shape.
- Centralized error handling that distinguishes network, 4xx, and 5xx failures.
- Timeouts and a single, configurable retry policy for idempotent calls.
- No secrets in code — read credentials from configuration/env.
- A short usage example for the two most common calls.

language

description: Language/runtime

description: API endpoints and shapes


title: Add Robust Error Handling

description: Harden a function or module against failure with deliberate error handling.

content:
Review the code below and add robust error handling:

```
{{code}}
```

For each failure mode, decide deliberately: validate-and-reject, retry, fall back, or propagate. Then:
- Validate inputs at the boundary; fail fast with actionable messages.
- Never swallow errors silently — log or rethrow with context.
- Distinguish expected failures (return/throw typed errors) from bugs (let them surface).
- Keep the happy path readable; don't drown it in try/catch.

Show the revised code and a one-line rationale per change.

code

description: The code to harden


title: Write a CLI Command

description: Build a command-line subcommand with argument parsing and good UX.

content:
Create a CLI command `{{command}}` in {{language}} that: {{behavior}}

Requirements:
- Parse flags and positional args with clear `--help` output.
- Validate arguments and exit with a non-zero code and a useful message on error.
- Support `--json` for machine-readable output where it makes sense.
- Be quiet on success by default; add `--verbose` for detail.
- Handle Ctrl+C cleanly.

command

description: Command name

language

description: Language/framework

behavior

description: What the command does


title: Concurrency-Safe Implementation

description: Implement logic that is correct under concurrent access.

content:
Implement the following with correct behavior under concurrency: {{task}}

In {{language}}:
- Identify the shared state and the exact invariants that must hold.
- Choose the simplest correct synchronization (immutability > message passing > locks).
- Avoid deadlocks and races; explain why your choice is free of both.
- Note the performance trade-off you made.

Provide the code plus a short paragraph on how it behaves under contention.

language

description: Language/runtime

task

description: The concurrent task


title: Design a Regular Expression

description: Build and explain a regex for a specific matching task.

content:
Write a regular expression that matches: {{requirement}}

Provide the pattern in {{flavor}} syntax, a plain-language breakdown of each part, 3 strings it SHOULD match and 3 it should NOT, and a note on any catastrophic-backtracking risk and how to avoid it. Prefer readability (named groups) over cleverness.

requirement

description: What the regex must match

flavor

description: Regex flavor (PCRE, JS, Python)

enum: PCRE JavaScript Python Go Java .NET Rust RE2


title: Choose a Data Structure

description: Pick the right data structure for an access pattern.

content:
I need to store and access data like this: {{access_pattern}}

Recommend the data structure. Compare the 2-3 viable candidates on the operations I care about (insert, lookup, delete, iterate, ordered) with their Big-O. State the memory trade-off and which one wins for MY pattern. Flag the structure people reach for by habit that would be wrong here.

description: How the data is written and read


title: Implement a State Machine

description: Model a process as an explicit finite state machine.

content:
Model this as a state machine: {{process}}

Define the states, the events/transitions between them, and the actions on each transition. Make illegal transitions impossible to represent. Implement it in {{language}} with a clear transition table or typed states. Call out the states that are easy to forget: error, timeout, cancelled.

process

description: The process to model

language

description: Target language


title: Add a Caching Layer

description: Introduce caching to a hot path correctly.

content:
I want to cache: {{what}}

Design the cache: the key, what to store, the eviction policy, and the TTL. Critically, define the INVALIDATION strategy: when does cached data go stale and how is it refreshed? Handle the cache-stampede and stale-read cases. Tell me how I will measure hit rate and whether this cache is even worth it.

what

description: What you want to cache


title: Optimize a Hot Path

description: Make a performance-critical piece of code faster.

content:
This code is on a hot path and too slow:

{{code}}

Profile it in your head first: what is the dominant cost (allocations, repeated work, I/O, bad complexity)? Propose the change with the highest payoff, not micro-tweaks. Show the optimized version, state the new complexity or the work removed, and confirm behavior is unchanged. Warn me if the speedup trades away readability or correctness, and tell me how to measure that it actually helped.

code

description: The slow code


title: Implement Pagination

description: Add correct pagination to a list endpoint or query.

content:
I need to paginate: {{what}}

Recommend cursor-based or offset-based for my case and say why. Show the implementation: the page size, how the cursor or offset is encoded, how the client asks for the next page, and how the last page is detected. Handle the edge cases: items inserted or deleted mid-iteration, an invalid cursor, and an empty result. Note the stability and performance trade-off of the choice.

what

description: What you are paginating


title: Write a Parser

description: Parse a structured text format into a usable structure.

content:
Write a parser for this format: {{format}}

Define the grammar or structure first, then implement it in {{language}}. Decide between a hand-written recursive-descent parser and a regex/split approach, and justify it. Produce clear errors with position info on malformed input rather than silently misparsing. Cover the tricky cases: nesting, escaping, whitespace, and empty input. Include a couple of example inputs and their parsed output.

format

description: The format to parse

language

description: Target language


title: Validate Untrusted Input

description: Validate and sanitize input at a trust boundary.

content:
This input crosses a trust boundary: {{input}}

Write validation that rejects anything that isn't explicitly allowed (allow-list, not deny-list). Define the shape, types, ranges, and formats that are valid, and the exact error for each violation. Normalize before comparing. Cover the attack-shaped cases: oversized, malformed, injection, and unexpected encodings. Tell me what to do on failure (reject vs coerce) and why reject is usually right here.

input

description: The untrusted input