Tail Recursive Generics

🌐Community
by marius-townhouse · vlatest · Repository

This skill implements tail recursion with generics for efficient and expressive code generation, optimizing performance and reducing stack overflows.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add tail-recursive-generics npx -- -y @trustedskills/tail-recursive-generics
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "tail-recursive-generics": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/tail-recursive-generics"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill enables AI agents to write tail-recursive functions in TypeScript. Tail recursion is a specific form of recursion where the recursive call is the very last operation performed, allowing for optimization into iterative loops by compilers. This results in more efficient and stack-safe code, especially important when dealing with large datasets or deeply nested operations.

When to use it

  • Optimizing Recursive Algorithms: When you have a recursive function that's causing stack overflow errors or is simply inefficient.
  • Functional Data Transformations: Transforming lists or arrays using recursion where performance is critical.
  • Implementing Custom Iterators: Creating custom iteration logic with improved efficiency and memory usage.
  • Code Refactoring: Converting existing recursive functions to a tail-recursive form for better performance.

Key capabilities

  • Generates tail-recursive TypeScript code from imperative or standard recursive structures.
  • Optimizes recursive function calls into iterative loops.
  • Improves stack safety and reduces the risk of stack overflow errors.

Example prompts

  • "Convert this recursive factorial function to a tail-recursive version in TypeScript."
  • "Refactor this sumArray function using tail recursion in TypeScript."
  • "Write a tail-recursive function in TypeScript that calculates the nth Fibonacci number."

Tips & gotchas

  • Requires a basic understanding of recursion and functional programming concepts.
  • Not all recursive functions can be easily converted to tail-recursive forms; some may require significant restructuring.

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
marius-townhouse
Installs
4

🌐 Community

Passed automated security scans.