ai-upgrade

A coding command that adds AI or machine-learning behavior to an existing feature while keeping its original behavior available.

In plain words
What is it for?
Use it to upgrade features such as search, metrics, or catalog functions in Python, Node.js, Java, or other codebases.
Why use it?
It helps introduce AI without replacing the current feature or making the whole feature fail when the AI service is unavailable.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/alphaaiservice/cortex/ai-upgrade
Clone the repo
git clone --depth 1 https://github.com/alphaaiservice/cortex
Per session 36 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,060 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00036 $0.04060
Opus 5 $0.00018 $0.02030
Sonnet 5 $0.00007 $0.00812
Haiku 4.5 $0.00004 $0.00406

Measured 2d ago against content hash 9f23a59943d2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ai-upgrade scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/ai-upgrade.md · 536 lines

How it starts

The opening of the file, as written. The whole thing — 536 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI Upgrade — Add AI Capabilities to an Existing Feature

Upgrade this feature with AI: $ARGUMENTS

This is the implementation command. It takes an existing feature in the codebase and adds AI/ML capabilities to it. Works for ANY stack — Python/FastAPI, Node.js/NestJS, Java/Spring Boot, or any other.

KEY PRINCIPLE: Enhance, do not replace. The existing feature must continue to work. AI adds a layer on top — if the AI service is down, the feature falls back to its original behavior.


Step 1: Identify the Target Feature

1.1: Find the Feature in Codebase

# Search for the feature by name across the codebase
grep -rn "$ARGUMENTS" . --include="*.py" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.java" --include="*.go" -l 2>/dev/null | head -20

# Search in directory names
find . -type d -iname "*$ARGUMENTS*" -not -path "*/node_modules/*" -not -path "*/.git/*"

# Search in route definitions
grep -rn "/$ARGUMENTS\|$ARGUMENTS" . --include="*route*" --include="*controller*" --include="*handler*" -l 2>/dev/null

1.2: Analyze Current Implementation

Read the feature's files across all layers:

CURRENT IMPLEMENTATION ANALYSIS
════════════════════════════════
Feature: [name]
Description: [what it does now]

Database:
  Tables: [list]
  Key queries: [types of queries — CRUD, search, aggregation]

Backend:
  Models: [files]
  Services: [files + key methods]
  Controllers: [files + endpoints]
  Current logic: [brief description of business logic]

Frontend:
  Pages: [files]
  Components: [files]
  Current UX: [how the user interacts with this feature]

Pain Points (inferred from code):
  1. [limitation of current implementation]
  2. [missing capability]
  3. [poor UX pattern]

Step 2: Design the AI Enhancement

Based on the feature type, select the appropriate AI upgrade pattern:

Search Features → Semantic Search

Enhancement: Semantic Search with Vector Embeddings
  Current: SQL LIKE / full-text search
  Upgrade: Embed content → vector DB → similarity search → re-rank

  Components:
    - Embedding pipeline (batch + real-time)
    - Vector storage (Qdrant / pgvector / Pinecone)
    - Hybrid search (keyword + semantic)
    - Result re-ranking with LLM

Read the full file on GitHub · 536 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 536 lines · 36 tokens per session scan A 9f23a59943d2

Subscribe to this mod's changes

ai-upgrade is a command published in the GitHub repository alphaaiservice/cortex (1 stars, last pushed 26d ago), licensed MIT. It adds 36 tokens to every session and 4,060 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.