Works with the AI Agents you already use

    context slice

    by 左岸奶茶

    0

    ContextSlice: AST-based code pre-compiler that trims code context to save tokens for AI models. Use to avoid context overflow and minimize token usage by 80-90%.

    Free

    Security scanned

    What it does

    • Shrinks code size by over 80 percent while keeping the logic clear for the AI agent
    • Map connections between files so the agent understands the whole project structure
    • Supports many languages like Python, JavaScript, Java, C#, and Ruby
    • Works locally on your computer to keep your private code off external servers
    • Helps avoid memory errors where the AI agent loses track of long conversations

    Who it's for

    Developers working on large projects

    Send long files to your AI without hitting memory limits or wasting money.

    Try asking: “Trim my login.ts file so I can fix the auth bug without hitting the token limit.”

    Technical founders managing costs

    Slash your AI bill by removing 80% of unnecessary code from your requests.

    Try asking: “Shrink my Django project code so I can ask the AI for a feature review cheaply.”

    Freelancers auditing unfamiliar code

    Get a clear map of how code files connect without reading every single line.

    Try asking: “Show me how the files in this React project talk to each other.”

    context slice

    Example session with this skill installed

    1. 開啟 ContextSlice:打開瀏覽器,載入 ContextSlice Studio

    2. 輸入查詢:在搜尋框輸入關鍵字,例如 "login" 或 "auth"

    3. 設定參數:選擇 1-2 層相關,設定 token 上限 4000

    4. 查看結果:右側面板顯示:

      • 精簡後的程式碼片段
      • 只保留關鍵函式與參數
      • 其餘程式自動摺疊
    5. 輸出結果:點擊「複製給 AI」或「匯出 PDF」給 AI 使用

    • Read your context and instructions
    • Compiled the context slice

    I have analyzed the project structure and generated a context-optimized slice centered on the login logic. By pruning non-essential implementations and keeping only signatures for distant dependencies, I reduced the token footprint by approximately 85%.

    Optimized Code Slice

    // File: src/auth/service.ts
    import { db } from "../database";
    import { encrypt } from "../utils/crypto";
    
    /**
     * CORE LOGIC (Full Implementation Kept)
     */
    export async function login(username, password) {
      const user = await db.users.findUnique({ where: { username } });
      if (!user) throw new Error("User not found");
      
      const isValid = await encrypt.compare(password, user.hash);
      if (isValid) {
        return generateToken(user.id);
      }
      return null;
    }
    
    /**
     * DEPENDENCIES (Signatures Only)
     */
    // File: src/utils/crypto.ts
    export const encrypt = {
      compare: (plain: string, hash: string): Promise<boolean> => { /* implementation hidden */ },
      hash: (plain: string): Promise<string> => { /* implementation hidden */ }
    };
    
    // File: src/database/index.ts
    export const db = {
      users: {
        findUnique: (args: any): Promise<any> => { /* implementation hidden */ }
      }
    };
    

    Next steps

    1. Review the login implementation in the provided slice for logical flaws.
    2. If the issue lies in the hashing algorithm, request a slice focusing on src/utils/crypto.ts.
    3. Provide the specific error log to further refine the pruning priorities.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    ContextSlice - AI Token 省錢神器

    這是一個「免費」的開源工具,幫助你用更少的 tokens 分析程式碼,避免 AI 對話中出現「上下文溢位」問題。

    🎯 為什麼需要這個工具?

    當你請 AI 幫你改程式時,常常會遇到:

    1. 一次貼太多檔案,Token 花費爆表:改一個功能往往牽涉好幾個檔案
    2. 單一檔案太長,貼不進對話框:幾千行的長檔案無法完美貼上
    3. 傳統 AI 工具說明書太肥:AI 每輪對話都要先消耗大量 tokens

    ✨ ContextSlice 的做法:

    • 在瀏覽器或本機幫程式碼畫出關聯圖
    • 把「要改的重點」留完整,只把「相關的程式」留標題與參數外框
    • 其餘「無關程式」自動略過,避免不必要的 Token 消耗

    🚀 使用方式:

    方法 1:一鍵啟動(建議)

    # 進到你的專案資料夾
    node start.mjs
    
    方法 2:手動安裝 CLI 工具
    # 下載這支腳本到你的工具資料夾
    node tools/ctxslice-mcp.mjs "login" --budget 4000 --hops 1
    
    方法 3:用 MCP 服務(與 Claude Code / OpenCode / Pi Agent 整合)
    claude mcp add --scope user context-slice -- node tools/ctxslice-mcp.mjs
    
    🌐 支援的程式語言:
    
    TypeScript/JavaScript、Python、Go、C/C++、Swift、PHP、HTML/Vue/Svelte、CSS/SCSS、Rust、Java/Kotlin、C#、Ruby、
    SQL
    
    📊 實測效果(參考):
    
    ┌────────────────────┬───────────────┬──────────────┬────────┐
    │        專案        │   原始大小    │    精簡後    │ 節省率 │
    ├────────────────────┼───────────────┼──────────────┼────────┤
    │ 中型 Node.js 專案  │ 48,000 tokens │ 6,200 tokens │ 87%    │
    ├────────────────────┼───────────────┼──────────────┼────────┤
    │ 前端 React 專案    │ 32,000 tokens │ 4,100 tokens │ 87%    │
    ├────────────────────┼───────────────┼──────────────┼────────┤
    │ Python Django 專案 │ 38,000 tokens │ 5,300 tokens │ 86%    │
    └────────────────────┴───────────────┴──────────────┴────────┘
    
    💡 常見使用場景:
    
    - Claude Code / Copilot / Cursor 中的自動上下文管理
    - ChatGPT / 網頁版 AI 複製貼上前的預處理
    - GitHub PR Review 前的程式碼摘要
    - 技術文件產出 前的結構梳理
    
    🔐 隱私保護:
    
    所有程式碼解析、依賴建圖、基準測試與精簡封包產生皆在您的電腦本機記憶體內完成,不會將您的原始碼傳送至外部伺服器
    。
    

    Requires Node.js runtime. Pruning effectiveness depends on accurate AST parsing of the specific language syntax.

    Built as an AST-based code pre-compiler. Uses a Node.js script (start.mjs or ctxslice-mcp.mjs) to parse code into an abstract syntax tree and prune non-essential nodes based on a specified token budget and 'hops' (dependency distance). Supports MCP integration for Claude Code and similar agents. Processes data in local memory to ensure privacy.

    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 today

    • Free with an Agensi account

    Software
    Node.js v20+ (local installation required)

    Permissions

    Terminal / Shell
    Read Files
    Environment Variables
    Browser

    Allowed Hosts

    node.js

    File Scopes

    File
    Scopes:
    **/*
    #
    Read
    all
    files
    !**/node_modules/**
    Exclude
    node_modules
    !**/.git/**
    .git
    !**/dist/**
    dist
    !**/build/**
    build
    Notes:
    -
    This
    is
    a
    read-only
    tool:
    ContextSlice
    analyzes
    code
    but
    never
    modifies
    them
    All
    file
    reading
    happens
    locally
    with
    no
    network
    transfer
    The
    tool
    scans
    for
    AST
    symbols
    to
    context
    relationships
    Privacy-first:
    are
    processed
    only
    in
    local
    memory
    Listed13 days ago
    Updatedtoday

    What's inside

    Creator

    左岸奶茶

    左岸奶茶

    BM6HNS

    Frequently Asked Questions

    Context Slice is an AST-based pre-compiler that analyzes your codebase to strip away boilerplate and irrelevant implementation details, leaving only the essential logic and signatures needed for an LLM to understand your project structure without hitting token limits.

    This skill is optimized for CLI-based tools like Claude Code and OpenCode, but it also supports Pi Agent and can be used to pre-process code blocks for any web-based model like ChatGPT.

    Yes, Context Slice runs entirely in your local memory to map dependencies and prune logic, ensuring your proprietary source code is never uploaded to an external server during the slicing process.

    The tool features a built-in budget enforcement flag (e.g., --budget) that allows you to set a hard token limit, ensuring the output fits perfectly within your specific model's context window.

    https://github.com/grundy40/ContextSlice

    New in Prompt & Skill Engineering

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Prompt & Skill Engineering.

    Free