alivirgo/major-ai-skills/type-alias-compression

Claude Code and agent skill by alivirgo/major-ai-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Extract repeated complex type expressions into named aliases that keep signatures readable.

Install

npx vskill@latest install alivirgo/major-ai-skills/type-alias-compression

SKILL.md

Type Alias Compression Protocol (Generic Signature Normalization)

Overview

When writing enterprise applications in TypeScript, Python, or Rust, complex nested generic signatures (e.g., `Promise<AxiosResponse<PaginatedResponse<UserProfileDTO>>>`) are frequently repeated across 10 to 20 method definitions in a single module.

Repeating nested generic signatures causes:

  1. Severe Token Multiplication: Repeating an 80-character generic signature across 15 functions burns 400+ output tokens on syntax boilerplate.
  2. Maintenance Drift: Changing the underlying response envelope requires mutating 15 separate function signatures across the file.
  3. Cognitive Clutter: The actual function argument names are pushed off-screen by long type annotations.

The Type Alias Compression Protocol extracts common nested generic patterns into concise top-level type aliases (`type Res<T> = ...`), normalizing signatures to 1 to 2 clean tokens.


Repetitive Nested Generics vs. Compressed Type Aliases

┌─────────────────────────────────────────────────────────────┐
│ Type Signature Token Density │
│ │
│ Repetitive Nested Generics (15 Methods / 420 Tokens): │
│ export async function getUser(id: string): │
│ Promise<AxiosResponse<ApiResponse<PaginatedResult<User>>>>{...}│
│ export async function getOrg(id: string): │
│ Promise<AxiosResponse<ApiResponse<PaginatedResult<Org>>>>{...} │
│ ↳ 420 tokens billed purely repeating identical generic wraps│
│ │
│ Compressed Type Alias (1 Definition / 65 Tokens): │
│ type ApiPage<T> = Promise<AxiosResponse<ApiResponse<PaginatedResult<T>>>>;│
│ export async function getUser(id: string): ApiPage<User> {...}│
│ export async function getOrg(id: string): ApiPage<Org> {...} │
│ ↳ 65 clean tokens (84.5% Reduction!), single point of change│
└─────────────────────────────────────────────────────────────┘

Multi-Language Type Alias Compression Recipes

1. TypeScript / JavaScript
typescript
// 1. Define High-Frequency Aliases at Top of File
export type AsyncResult<T> = Promise<{ data: T; error: null } | { data: null; error: string }>;
export type Handler<TReq, TRes> = (req: Request<TReq>, res: Response<TRes>) => Promise<void>;
export type ID = string | number;
// 2. Ultra-Clean Method Signatures
export async function fetchUser(id: ID): AsyncResult<User> { ... }
export async function updateProfile(id: ID, payload: UserDto): AsyncResult<User> { ... }

2. Python 3.12+ (PEP 695 Type Aliases)
python
from typing import Callable, Coroutine, Any
# Python 3.12 native type statement
type JsonResult[T] = Coroutine[Any, Any, dict[str, T]]
type MiddlewareFn = Callable[[Request, Callable], Response]
async def get_user_profile(user_id: str) -> JsonResult[UserProfile]:
...

3. Rust Type Aliasing
rust
use std::result::Result as StdResult;
// Aliasing heavy error types across the crate
pub type Result<T> = StdResult<T, AppEngineError>;
pub type UserMap = std::collections::HashMap<String, UserProfile>;
pub fn get_user(id: &str) -> Result<UserProfile> { ... }

Benchmark Comparison

Generating a standard 12-method REST API controller:

Implementation PatternTotal Signature TokensRefactoring FrictionAST Complexity
Inline Nested Generic Signatures980 tokens12 files to changeHigh ($>18$ nodes/sig)
Compressed Type Alias Protocol340 tokens1 alias to changeLow (2 nodes/sig)

Agent Operational Directive

MANDATORY: When a nested generic type signature is used $\ge 2$ times in a file or module, agents must extract it into a top-level type alias (type Result<T> = ...). Never repeat multi-layered generic chains across function signatures.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
7-day trend score
3

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/alivirgo/major-ai-skills/type-alias-compression/badge)](https://verified-skill.com/skills/alivirgo/major-ai-skills/type-alias-compression)

Something wrong with this skill or its page? Tell us.