Works with the AI Agents you already use

    Local LLM Code Architect & Token Optimizer

    by Tushar

    1

    Supercharge local LLMs (Qwen 2.5, DeepSeek, Llama 3) for large codebases. Enforces strict context budgeting, AST-guided diffing, and zero-hallucination planning.

    $5

    /mo

    Subscription · cancel anytime

    Secure checkout via Stripe

    • Always the latest version
    • Delivered live to your agent via MCP
    • Cancel anytime, access ends at period end
    Security scanned
    Local LLM Code Architect & Token Optimizer

    Local LLM Code Architect & Token Optimizer

    Example session with this skill installed

    Refactor 'src/auth/session.ts' to add a Redis cache layer for user lookups before hitting Prisma. Keep it token-efficient for my local Qwen 2.5-Coder 14B model without rewriting the entire 450-line file.

    • Read your context and instructions
    • Compiled the local llm code

    Summary

    Compressed architectural context for src/auth/session.ts from 1,840 tokens down to 185 tokens (-89.9% reduction) and applied surgical Redis session caching without touching untouched methods.

    MetricFull File PromptingContext-Budgeted AST Approach
    Prompt Token Consumption1,840 tokens185 tokens (-89.9%)
    Response Latency (Local 14B)14.8 seconds2.9 seconds
    Risk of Truncation (// ... rest)High (Common on 7B/14B)0% (Enforced Surgical Diff)
    Files ModifiedFull destructive overwriteSurgical 18-line diff block

    1. Token-Budgeted AST Context Skeleton

    // src/auth/session.ts (Compressed Skeleton)
    export interface UserSessionPayload { userId: string; role: 'admin' | 'member'; }
    export class AuthenticationMiddleware {
      public verifySession = async (req: AuthenticatedRequest, res: Response, next: NextFunction): Promise<void>;
    }
    

    2. Surgical Search-and-Replace Block (src/auth/session.ts)

    <<<<<<< SEARCH
          const userExists = await db.user.findUnique({
            where: { id: decoded.userId },
            select: { id: true, active: true, role: true }
          });
    =======
          // 1. Check Redis fast memory cache first
          let userExists: any = null;
          try {
            const cached = await redisClient.get(`user:session:${decoded.userId}`);
            if (cached) userExists = JSON.parse(cached);
          } catch (cacheErr) {
            logger.warn('Redis cache lookup failed, falling back to DB', { error: cacheErr });
          }
    
          // 2. Fallback to PostgreSQL via Prisma if cache miss
          if (!userExists) {
            userExists = await db.user.findUnique({
              where: { id: decoded.userId },
              select: { id: true, active: true, role: true }
            });
            if (userExists) {
              await redisClient.setEx(`user:session:${decoded.userId}`, 300, JSON.stringify(userExists)).catch(() => {});
            }
          }
    >>>>>>>
    

    3. Dependency Verification Check

    • Confirmed ioredis / redis package is installed in package.json.
    • Confirmed redisClient instance is exported from src/utils/redis.ts.

    Next steps

    • Review and apply the surgical diff block above.
    • Run npm test -- test/auth/session.test.ts to verify the Redis fallback and cache-hit behavior.
    $5/mo

    Subscription · always the latest version

    • Secure checkout via Stripe
    • Cancel anytime
    • Delivered live via MCP

    About this skill

    Turn Local Open-Weight Coding LLMs Into 10x Senior Software Engineers

    Running local models like Qwen 2.5-Coder 7B/14B/32B, DeepSeek-Coder, or Llama 3 Code on your own hardware gives you total privacy and zero API bills. But on real production codebases, local models often fall flat:

    • They choke on large 500+ line files, blowing through their effective attention window.
    • They emit lazy shortcuts like // ... rest of code stays the same ... that wipe out your source code.
    • They rewrite entire multi-hundred line files just to update one variable, introducing syntax bugs.
    • They hallucinate fake npm/pip packages that don't exist.

    Local LLM Code Architect solves these systemic problems with structured AST context extraction, strict context window budgeting, and precision surgical search-and-replace protocols.


    Key Capabilities

    • 70%–90% Context Reduction: Bundled context_budgeter.py extracts public class/type interfaces and function signatures, keeping local models well within their high-attention token budget.
    • Eliminates Truncation Bugs: Enforces strict bans on placeholder comments (// ... rest unchanged) and mandates verifiable surgical diffs.
    • Zero Phantom Packages: Enforces pre-flight dependency checking against package.json and pyproject.toml before writing code.
    • Universal Compatibility: Works seamlessly with Ollama, LM Studio, vLLM, Cursor with local endpoints, Claude Code, and Copilot.
    • Includes AST CLI: Run python scripts/context_budgeter.py ./src --budget 3000 to prepare token-efficient context prompts automatically.

    Requires Python for the context_budgeter.py script. Cannot automatically install missing system-level binaries.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 13 days ago

    Software
    Python 3.9+

    Zero cloud dependencies. Runs entirely on your local machine with full data privacy. Compatible with any local LLM runner (Ollama, LM Studio, vLLM).

    Permissions

    Terminal / Shell
    Read Files
    Write Files

    File Scopes

    src/**
    lib/**
    tests/**
    package.json
    pyproject.toml
    Listed13 days ago

    What's inside

    Frequently Asked Questions

    This skill solves 'lazy' output (placeholders like // rest of code unchanged) and context saturation by using AST-based budgeting and enforcing strict search-and-replace protocols that prevent destructive file rewrites.

    It is optimized for local runners like Ollama, LM Studio, and vLLM, specifically targeting models like Qwen 2.5 Coder, DeepSeek-Coder, and Llama 3 (7B to 32B parameters).

    You will receive the operational logic for the agent, the `context_budgeter.py` CLI tool for AST compression, and the integration protocols for surgical search-and-replace workflows.

    The skill requires a Python environment to run the AST budgeting script and works best in projects using Python or TypeScript where dependency verification is needed.

    Yes, the surgical diff protocol and AST skeleton generation are designed to handle files exceeding 500 lines by only feeding the model relevant headers and specific logic blocks rather than the entire file.

    While it automates logic updates and imports, it does not automatically install missing system-level binaries; you must ensure the base environment satisfies the project's core dependencies.

    It is optimized for Qwen 2.5-Coder (7B, 14B, 32B), DeepSeek-Coder-V2, and Llama 3.1/3.2/3.3, but works with any LLM running on Ollama, LM Studio, or local API servers.

    No, it enhances them! You can use this inside Cursor with local Ollama models or with cloud models to drastically slash your monthly token usage.

    It parses the syntax tree to keep imports, exported interfaces, types, and function signatures while stripping internal implementation bodies, saving up to 90% of tokens while preserving 100% of architectural context.

    New in LLM Ops

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.