Works with the AI Agents you already use
Cortex
Codebase intelligence engine that indexes repositories using AST syntactic chunking and tri-hybrid retrieval to answer queries with verified line-level citations.
Free
Cortex
Example session with this skill installed
Using the Cortex MCP tools, inspect our authentication pipeline: locate verifyAccessToken, trace its entire caller graph and refactoring blast radius across the codebase, and provide a structured plan to add multi-tenant validation (tenantId) without breaking downstream services. Ground all findings with exact file and line citations.
- Read your context and instructions
- Compiled the cortex
I have analyzed verifyAccessToken and its complete dependency graph using Cortex MCP tools (search_code, get_function, and trace_deps). Below is the architectural breakdown, blast radius assessment, and safe refactoring implementation plan.
1. Executive Summary & Verification
- Target Symbol:
verifyAccessToken - Location:
packages/core/src/auth/jwt.ts:42-88 - Current Signature:
(token: string, options?: VerifyOptions) => Promise<UserPayload>
Blast Radius Risk:
CRITICAL (4 direct consumers, 2 background workers, and 1 websocket handshake pipeline depend on this return payload).
- Index Status: Verified against AST commit
c89a42fvia Cortex tri-hybrid retrieval.
2. Upstream Caller & Blast Radius Inventory
Running trace_deps identified
5 core call sites that consume verifyAccessToken. All 5 will break if the payload shape changes without backwards compatibility:
| Component / File | Location | Consumption Pattern | Impact / Risk |
|---|---|---|---|
API Gateway Auth Middleware<br>apps/api/src/middleware/auth.ts | Lines 28–54 | Injects req.user = payload into HTTP context | CRITICAL — Entry point for all protected REST endpoints |
WebSocket Connection Guard<br>apps/api/src/ws/connection.ts | Lines 61–79 | Extracts payload.sub for socket room subscription | HIGH — Real-time event broadcasting |
Billing Webhook Controller<br>services/billing/src/webhook.ts | Lines 112–135 | Validates service-to-service bearer tokens | HIGH — Automated invoice & subscription webhooks |
Audit Logger Interceptor<br>packages/core/src/logging/audit.ts | Lines 18–37 | Reads payload.userId and payload.role | MODERATE — Structured compliance logs |
User Unit Test Suite<br>packages/core/src/auth/__tests__/jwt.test.ts | Lines 15–90 | 8 unit tests asserting current payload shape | LOW — Test fixtures require mock update |
3. Implementation Code Analysis
Retrieved via get_function("verifyAccessToken"):
// packages/core/src/auth/jwt.ts:42-88
export async function verifyAccessToken(
token: string,
options: VerifyOptions = {}
): Promise<UserPayload> {
const decoded = jwt.verify(token, process.env.JWT_SECRET!, {
algorithms: ['HS256'],
issuer: 'cortex-auth',
...options,
}) as RawJwtPayload;
if (!decoded.sub || !decoded.role) {
throw new UnauthorizedError('Malformed access token claims');
}
return {
userId: decoded.sub,
role: decoded.role,
scopes: decoded.scopes ?? [],
};
}
4. Non-Breaking Refactoring Implementation
To introduce tenantId without breaking existing callers that do not yet provide multi-tenant headers, update the contract to support optional multi-tenancy with strict validation for tenant-aware routes:
// packages/core/src/auth/jwt.ts
export interface UserPayload {
userId: string;
role: string;
scopes: string[];
tenantId?: string; // Non-breaking optional addition
}
export async function verifyAccessToken(
token: string,
expectedTenantId?: string,
options: VerifyOptions = {}
): Promise<UserPayload> {
const decoded = jwt.verify(token, process.env.JWT_SECRET!, {
algorithms: ['HS256'],
issuer: 'cortex-auth',
...options,
}) as RawJwtPayload;
if (!decoded.sub || !decoded.role) {
throw new UnauthorizedError('Malformed access token claims');
}
// Enforce tenant isolation if tenant is specified or present in token claims
if (expectedTenantId && decoded.tenant_id && decoded.tenant_id !== expectedTenantId) {
throw new ForbiddenError('Cross-tenant token usage rejected');
}
return {
userId: decoded.sub,
role: decoded.role,
scopes: decoded.scopes ?? [],
tenantId: decoded.tenant_id,
};
}
5. Recommended Next Steps
Update Middleware: Modify apps/api/src/middleware/auth.ts:34 to pass req.headers['x-tenant-id'] as the second argument to verifyAccessToken.
2.
Update WebSocket Handshake: Verify tenant isolation during connection upgrade in apps/api/src/ws/connection.ts:65.
3.
Resync Index: Once edits are committed, run Cortex incremental sync to refresh AST symbol references in milliseconds:
// MCP call: sync_repository
{ "repo_id": "3f8a91c2-b5e4-4d89-9a11-e6c1a8d0714b" }
Connects securely to your tools. The creator never sees your data.
About this skill
Navigating a massive, unfamiliar codebase is a recipe for hallucinations and wasted hours. Most AI search tools rely on naive text splitting that breaks function signatures and loses type context, leading to incorrect localizations and broken refactorings.
Cortex transforms any repository into an AST-grounded intelligence graph, allowing AI agents to navigate, inspect, and reason over complex codebases with line-level verified citations.
What It Does
- AST Syntactic Chunking: Parses code using Tree-sitter grammars to ensure functions, classes, and methods are never truncated mid-declaration.
- Tri-Hybrid Retrieval Engine: Fuses dense vector embeddings (
all-MiniLM-L6-v2), BM25 lexical tokens, and AST dependency graph hops using Reciprocal Rank Fusion (RRF). - Dependency & Call Graph Tracing: Traverses directed call graphs to identify every upstream caller, downstream callee, and dependent for any symbol or file.
- Grounded Line Citations: Every answer is anchored to verified file paths and exact line ranges (
path/to/file.ts:45-82), eliminating speculative imports and non-existent methods. - Sub-Second Git Diff Sync: Leverages Git diffs against the last indexed commit to update the knowledge base in milliseconds without re-indexing unchanged files.
How It Works
Cortex exposes 5 dedicated MCP tools that combine into powerful multi-step agent workflows:
index_repository: Ingests a local directory path or remote Git URL into an embedded AST vector and graph store.search_code: Performs hybrid semantic, lexical, and graph search using natural language or technical keywords to discover relevant symbols.get_function: Retrieves the complete declaration, type signature, and implementation body for an exact symbol name.trace_deps: Maps incoming and outgoing dependencies to evaluate caller chains and refactoring blast radius.sync_repository: Runs instant incremental diff synchronization following local file modifications.
Technical Stack & Architecture
- Protocol: Standard Model Context Protocol (MCP) JSON-RPC 2.0 over
stdio. - Parsing: Multi-language Tree-sitter AST parsers for language-aware syntactic boundary extraction.
- Embeddings: Local, offline CPU embedding inference via
@xenova/transformers(Xenova/all-MiniLM-L6-v2). - Storage: Fully self-contained local embedded PGlite (Postgres in WebAssembly) and in-process vector store with zero external cloud database dependencies.
Why This Beats Prompting It Yourself
Standard code RAG severs the relationship between a class, its interface, and its methods by splitting files at arbitrary character boundaries.
Cortex operates at the AST syntax level. It preserves complete lexical scope, retains surrounding types, and traces actual symbol references—making it impossible for an agent to "miss" half a function body or hallucinate an import that does not exist.
High-Impact Use Cases
- Codebase Onboarding: Instantly map the architectural foundation, entry points, and request flows of an unfamiliar project.
- Blast Radius & Impact Analysis: Audit all upstream callers and downstream consumers before modifying a shared function signature or breaking an API.
- Deep Root-Cause Debugging: Trace an execution path end-to-end—from an HTTP controller through middleware layers down to database queries.
- Safe Refactoring: Pinpoint every concrete implementation of abstract classes and interfaces across thousands of files.
Compatible Environments
Plug-and-play with any MCP-enabled IDE or agent runner:
- Claude Desktop
- Cursor
- Windsurf
- Google Antigravity
- Cline / Roo Code
Known Limitations
- Read & Intelligence Engine: Designed for deep code intelligence, retrieval, and dependency tracing; does not directly apply file mutations to disk.
- Repository Indexing: Tools require an active repository UUID generated by
index_repositoryorcortex-rag cli index. - Initial Indexing: Very large monolithic codebases (>50,000 files) may take a few minutes for initial Tree-sitter parsing and embedding generation.
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.
Does not support direct file mutation. Initial indexing of extremely large repositories may take time. Requires a pre-indexed repository ID for most operations.
How to use
- 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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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 3 days ago
- Free with an Agensi account
- Accounts
Groq API Key
- Software
Node.js 20+Cortex MCP Server
Requires a working Cortex MCP server configuration and a Groq API key. Follow the included SETUP.md and CONFIG.md instructions to connect Cortex to your AI coding agent.