Skip to content
Back to skills

Semantic Key Shortening

ASecurity

Use familiar short field names in compact payloads when their meaning stays clear to producers and consumers.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 22, 2026
ai-agentstypescriptpythongoapi

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Scanned October 22, 2026

npx -y skills add alivirgo/Major-AI-Skills --skill semantic-key-shortening --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Semantic Key Shortening?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Semantic Key Shortening
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alivirgo-semantic-key-shortening/badge)](https://www.skillsdirectory.com/skills/alivirgo-semantic-key-shortening)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: semantic-key-shortening
description: "Use familiar short field names in compact payloads when their meaning stays clear to producers and consumers."
category: efficiency
risk: safe
source: self
source_type: self
date_added: "2026-08-26"
tags: ["json-compression", "semantic-keys", "abbreviations", "pydantic-aliases", "token-optimization", "structured-data"]
tools: ["claude", "cursor", "gemini", "codex", "lmstudio"]
---

# Semantic Key Shortening Protocol (JSON Payload Compression)

## Overview
In automated extraction, log processing, and multi-agent communications, models frequently emit structured JSON objects with long, descriptive multi-word keys (*`"source_file_absolute_path"`, `"target_destination_directory"`, `"error_diagnostic_message"`*).

In high-volume batch runs ($>500$ records), repeating 30-character descriptive keys on every JSON object consumes **thousands of redundant tokens** without adding any technical clarity.

The **Semantic Key Shortening Protocol** replaces verbose key names with **standardized developer abbreviations (`src`, `dst`, `err`, `req`, `res`, `fn`, `qty`)** - using client-side Pydantic and TypeScript aliases to expand them into full domain entities automatically.

---

## Verbose Descriptive Keys vs. Semantic Short Keys

```
┌─────────────────────────────────────────────────────────────┐
│                 JSON Key Token Density                      │
│                                                             │
│  Verbose Descriptive Keys (145 Tokens for 2 Records):       │
│  [                                                          │
│    {                                                        │
│      "source_file_path": "src/auth.ts",                     │
│      "destination_file_path": "dist/auth.js",               │
│      "compilation_error_message": "Type mismatch",          │
│      "status_execution_code": 1                             │
│    }                                                        │
│  ]                                                          │
│  ↳ 45 tokens per record billed on verbose key strings       │
│                                                             │
│  Semantic Short Keys (42 Tokens - 71.0% Cut!):              │
│  [                                                          │
│    {"src":"src/auth.ts","dst":"dist/auth.js","err":"Type mismatch","code":1}│
│  ]                                                          │
│  ↳ 16 tokens per record, 100% semantic clarity for LLMs     │
└─────────────────────────────────────────────────────────────┘
```

---

## The Standardized Abbreviation Dictionary

Use these universally recognized developer abbreviations in prompt schemas and tool definitions:

| Verbose Key Name | Semantic Short Key | Token Savings |
| :--- | :--- | :--- |
| `source_path` / `source_file` | **`src`** | **66% Reduction** |
| `destination_path` / `target` | **`dst`** | **75% Reduction** |
| `error_message` / `exception` | **`err`** | **70% Reduction** |
| `request_payload` | **`req`** | **75% Reduction** |
| `response_payload` | **`res`** | **75% Reduction** |
| `function_name` | **`fn`** | **80% Reduction** |
| `line_number` | **`line`** | **50% Reduction** |
| `quantity` / `count` | **`qty`** / **`cnt`** | **60% Reduction** |
| `configuration` | **`cfg`** | **75% Reduction** |
| `timestamp` / `created_at` | **`ts`** | **70% Reduction** |

---

## Production Python Pydantic Implementation (`Field(alias=...)`)

Define data models with short wire aliases and rich internal variable names:

```python
from pydantic import BaseModel, Field
from typing import List

class FileMutation(BaseModel):
    source_path: str = Field(alias="src")
    destination_path: str = Field(alias="dst")
    error_message: str = Field(alias="err", default="")
    status_code: int = Field(alias="code", default=0)

    class Config:
        populate_by_name = True

# Downstream client parses dense compact JSON automatically
raw_llm_json = '[{"src":"src/a.ts","dst":"dist/a.js","code":0}]'
mutations = [FileMutation.model_validate(item) for item in json.loads(raw_llm_json)]
print(mutations[0].source_path)  # Outputs: 'src/a.ts'
```

---

## TypeScript Schema Aliases

```typescript
export interface WireMutationPayload {
  src: string;
  dst: string;
  err?: string;
  code: number;
}

// Client-side mapper to rich domain model
export function fromWirePayload(wire: WireMutationPayload) {
  return {
    sourcePath: wire.src,
    destinationPath: wire.dst,
    errorMessage: wire.err,
    statusCode: wire.code,
  };
}
```

---

## Benchmark Comparison

Processing 1,000 continuous integration build log entries:

| Payload Representation | Total Output Tokens | Generation Duration | API Cost (GPT-4o) |
| :--- | :--- | :--- | :--- |
| **Verbose Descriptive Keys** | 58,000 tokens | 48.2 seconds | $0.580 |
| **Semantic Short Keys (`src`, `dst`)**| **24,500 tokens** | **18.5 seconds** | **$0.245 (57.7% Savings!)**|

---

## Agent Operational Directive
> **MANDATORY**: For high-volume structured outputs, log extractions, and multi-agent JSON payloads, agents must use standardized semantic short keys (`src`, `dst`, `err`, `req`, `res`, `fn`, `ts`). Let client-side Pydantic/TypeScript models expand wire aliases into rich domain properties.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.