npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

slimspec

v0.0.3

Published

Zero-Shot (de)compression of API specs into token-efficient representations

Downloads

4

Readme

slimspec banner waifu

  /$$$$$$  /$$ /$$                /$$$$$$                               
 /$$__  $$| $$|__/               /$$__  $$                              
| $$  \__/| $$ /$$ /$$$$$$/$$$$ | $$  \__/  /$$$$$$   /$$$$$$   /$$$$$$$
|  $$$$$$ | $$| $$| $$_  $$_  $$|  $$$$$$  /$$__  $$ /$$__  $$ /$$_____/
 \____  $$| $$| $$| $$ \ $$ \ $$ \____  $$| $$  \ $$| $$$$$$$$| $$      
 /$$  \ $$| $$| $$| $$ | $$ | $$ /$$  \ $$| $$  | $$| $$_____/| $$      
|  $$$$$$/| $$| $$| $$ | $$ | $$|  $$$$$$/| $$$$$$$/|  $$$$$$$|  $$$$$$$
 \______/ |__/|__/|__/ |__/ |__/ \______/ | $$____/  \_______/ \_______/
                                          | $$                          
                                          | $$                          
                                          |__/            

SlimSpec : Towards Zero-Shot, API Spec Compression & Decompression

SlimSpec is a token-optimized format for representing API specifications with semantic precision. Designed for Zero-Shot LLM context window efficiency.

At the current iteration, It achieves 66% less tokens than traditional RAML.

Evaluations

3 Tests were done based on 3 examples: 1 - Simple CRUD API 2 - Complex E-commerce API 3 - Nested and recursive structures

Compression Test compression All popular LLMs appear to be able to compress SlimSpec to a similar token count.

Decompression Test decompression Sonnet > Gemini > Gpt-4o > Deepseek.

Rubric was tested with Zero-Shot decompression with NO CONTEXT WHATSOEVER.

Features

  • 60-70% token reduction compared to standard API specifications
  • Complete semantic preservation for lossless conversion
  • Support for complex type systems, inheritance, and validation rules
  • Preserves exact structure of request/response bodies
  • Maintains precision for date/time types, formats, and constraints

Installation

# Install globally
bun install -g slimspec

# Or run with bunx
bunx slimspec

Usage

# Compress all files in current directory
slimspec c .

# Compress specific file
slimspec c ./api-spec.raml

# Compress with specific model
slimspec c . --model openai:gpt-4o

# Compress with custom prompt
slimspec c . --prompt ./custom-prompt.txt

# Compress to custom output directory
slimspec c . --output ./compressed-specs
# Decompress all .apaic files in current directory
slimspec d .

# Decompress specific file
slimspec d ./api-spec.apaic

# Decompress with specific model
slimspec d . --model openai:gpt-4o

# Decompress with custom prompt
slimspec d . --prompt ./custom-decompress-prompt.txt

# By default, fileps are saved in the same directory as the input file
# To save in a custom output directory:
slimspec d . --output ./decompressed-specs

Syntax Reference

Metadata

@meta{title:API Name,version:v1,baseUri:uri,mediaType:a/json}

Type Definitions

T:TypeName{field1:s!,field2:i?,nested:{prop:s!}}
T:Child:Parent{additionalField:s!}

Error Definitions

E:ErrorType{code:i!,message:s!,details:s?}

Traits & Security

@trait:pagination{limit:i?=20,offset:i?=0}
@security:oauth2{tokenUri:s!,scopes:s[]}

Endpoints

GET/resources|{@trait:pagination}|{200(a/json):*Resource[],404:*Error}
POST/resources|{field1:s!,field2:i?}@originalInline|{201:*Resource,400:{message:s!}}
PUT/resources/{id:s!}|{*Resource}|{200:*Resource,404}
PATCH/resources/{id}|{field1:s?}|{200:*Resource,404}
DELETE/resources/{id}||{204,404}

Type System

  • s - string
  • i - integer
  • n - number
  • b - boolean
  • d(date) - date-only
  • d(datetime) - datetime
  • type[] - array
  • e(val1|val2) - enum
  • ! - required
  • ? - optional
  • ?=default - optional with default

Formats & Constraints

  • s(uuid) - UUID format
  • s(email) - Email format
  • s(uri) - URI format
  • s(3,100) - Min/max length
  • i>=0 - Minimum value
  • s~regex - Pattern matching

Example

RAML

types:
  User:
    properties:
      id: string
      email:
        type: string
        format: email
        required: true
      createdAt: datetime
/users:
  get:
    responses:
      200:
        body:
          application/json:
            type: array
            items: User

SlimSpec

@meta{mediaType:application/json}
T:User{id:s?,email:s(email)!,createdAt:d(datetime)?}
GET/users||{200(a/json):*User[]}

License

MIT