skate

repository·main·Indexed 23 days ago

https://github.com/charmbracelet/skate

A simple and powerful personal key-value store designed for local use. Skate supports strings, binary data, and Unicode, allowing users to organize data into multiple named databases. It provides a CLI for storing, retrieving, listing, and deleting key-value pairs, and is suitable for managing secrets or dynamic data within shell scripts.

Tokens
1.6K
Snippets
3
Records
12
Agent score
82%

What's inside skate

  1. Install Skate

    main

    You can install Skate using various package managers, downloading binaries/packages, or via Go.

    # macOS or Linux
    brew tap charmbracelet/tap && brew install charmbracelet/tap/skate
    
    # Arch Linux (btw)
    pacman -S skate
    
    # Nix
    nix-env -iA nixpkgs.skate
    
    # Debian/Ubuntu
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
    echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
    sudo apt update && sudo apt install skate
    
    # Fedora/RHEL
    echo '[charm]
    name=Charm
    baseurl=https://repo.charm.sh/yum/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
    sudo yum install skate
    
    # Go
    go install github.com/charmbracelet/skate@latest
  2. Use Skate to store and retrieve data

    main

    Skate is a personal key-value store. You can store strings, binary data, and Unicode characters. Note that as of v1.0.0, Skate operates locally and no longer syncs to the Charm Cloud.

    # Store a value
    skate set kitty meow
    
    # Fetch a value
    skate get kitty
    
    # Store binary data using redirection
    skate set profile-pic < my-cute-pic.jpg
    skate get profile-pic > here-it-is.jpg
    
    # Use Unicode keys/values
    skate set 猫咪 喵
    skate get 猫咪
  3. Use the skate CLI to manage key-value pairs

    main

    skate is a personal key-value store CLI. It allows you to store, retrieve, and list data within specific databases (spaces). You can specify a database using the @DB suffix on keys or as a standalone argument.

    Key Syntax

    • Key with Database: KEY@DB
    • Default Database: If no @DB is provided, skate uses the default database.

    Common Commands

    • set: Store a value.
    • get: Retrieve a value.
    • delete: Remove a key.
    • list: View keys and values.
    • list-dbs: See all available databases.
    • delete-db: Remove an entire database.
  4. Use Skate in shell scripts

    main

    Skate is useful for managing secrets or dynamic data within shell scripts without hardcoding values.

    # Example: Using a stored token in a curl command
    skate set gh_token GITHUB_TOKEN
    
    #!/bin/bash
    curl -su "$1:$(skate get gh_token)" \
        https://api.github.com/users/$1 \
        | jq -r '"\(.login) has \(.total_private_repos) private repos"'
  5. Set a value with skate set

    main

    The set command stores a value for a specific key. You can provide the value as a command-line argument or via standard input (useful for large files or binary data).

    Usage

    skate set KEY[@DB] [VALUE]

    Examples

    # Set a simple string value
    skate set foo bar
    
    # Set a value for a specific database
    skate set foo@my-space bar
    
    # Set a value by reading from a file via stdin
    skate set foo < ./bar.txt
  6. List keys and values with skate list

    main

    The list command iterates through the database. You can filter the output to show only keys, only values, or use a custom delimiter.

    Usage

    skate list [@DB]

    Flags

    • -r, --reverse: List in reverse lexicographic order.
    • -k, --keys-only: Only print keys; do not fetch values.
    • -v, --values-only: Only print values.
    • -d, --delimiter STRING: Delimiter to separate keys and values (default is \t).

    Examples

    # List all key-value pairs (default delimiter: tab)
    skate list
    
    # List only keys in a specific database
    skate list @my-space --keys-only
    
    # List values in reverse order
    skate list --reverse --values-only
    
    # List keys and values using a colon as a delimiter
    skate list -d ":"
  7. Get a value with skate get

    main

    The get command retrieves the value associated with a key. If the value is binary and not valid UTF-8, it will be omitted in the terminal unless the --show-binary flag is used.

    Usage

    skate get KEY[@DB]

    Examples

    # Get value from default database
    skate get foo
    
    # Get value from a specific database
    skate get foo@my-space
    
    # Get value and show raw binary data
    skate get foo@my-space --show-binary
  8. Manage databases with list-dbs and delete-db

    main

    Skate organizes data into named databases (spaces). You can view all existing databases or delete one entirely.

    List Databases

    Use list-dbs (alias ls-db) to see all available databases in your local storage.

    skate list-dbs

    Delete a Database

    Use delete-db (aliases del-db, rm-db) to remove a database and all its contents. This command will prompt for confirmation.

    # Delete the database named 'my-space'
    skate delete-db my-space

    Note: If you mistype a database name, skate will attempt to suggest the closest match using Levenshtein distance.

  9. Delete a key with skate delete

    main

    The delete command removes a key and its associated value from the database. It supports aliases del and rm.

    Usage

    skate delete KEY[@DB]

    Examples

    # Delete key from default database
    skate delete foo
    
    # Delete key from a specific database
    skate delete foo@my-space
  10. Reference: skate CLI commands

    main
    CommandAliasesDescription
    setSet a value for a key (optionally in a specific DB)
    getGet a value for a key
    deletedel, rmDelete a key
    listlsList key-value pairs
    list-dbsls-dbList all available databases
    delete-dbdel-db, rm-dbDelete an entire database