SuperAPI AI Directory

redis-crud

General & other

View repository

Updated 10-15 21:41

About this skill

Redis CRUD

Safely inspect and change Redis keys through saved local profiles. The skill uses a Bash script and redis-cli; it does not depend on Python or jq.

Purpose

Use this skill for:

  • saving reusable Redis connection profiles
  • direct Redis CLI connections
  • SSH tunnel connections to private Redis hosts
  • SSH remote execution where REDIS_URL exists on a server, such as a remote .env file
  • PING, GET, SET, DEL, HGET, HSET, HGETALL, SCAN, and guarded raw Redis commands

Output:

  • JSON printed to stdout
  • the same JSON saved to ./out/redis-crud-<UTC timestamp>-<pid>.json by default

Safety Rules

  • Never save Redis credentials in this repository.
  • Use ~/.config/redis-crud/profiles/<profile>.conf for saved profiles.
  • Do not print passwords or full Redis URLs; use list-profiles for redacted output.
  • Prefer read-only commands unless the user clearly asks to mutate data.
  • SET, DEL, HSET, and raw write commands dry-run by default.
  • Run structured writes with --execute only after explicit user confirmation.
  • Raw write commands require both --execute and --allow-raw-write.
  • readonly profiles must not be used for write commands.
  • Prefer structured commands over raw-command.
  • Prefer repeated raw-command --arg values when keys or values contain spaces; --command remains available only for simple space-separated commands.

What This Skill Needs

  • bash
  • local redis-cli for direct and ssh-tunnel profiles
  • ssh for ssh-tunnel and ssh-remote profiles
  • remote bash and redis-cli for ssh-remote profiles
  • one of nc, lsof, ss, or netstat for SSH tunnel port checks; the script does not use Bash /dev/tcp

Profile Storage

Profiles are saved under:

~/.config/redis-crud/profiles/

The default profile name is saved at:

~/.config/redis-crud/default_profile

Each profile is a 0600 shell-style config file. Example:

MODE=ssh-remote
READONLY=true
SSH_ALIAS=app-prod
REMOTE_CWD=/server/app
ENV_FILE=.env
ENV_KEY=REDIS_URL

Do not edit this file by hand unless needed; prefer configure.

Configure Profiles

Direct Redis

Prefer a full Redis URL when available:

bash <skill-path>/scripts/redis_crud.sh configure \
  --profile local \
  --mode direct \
  --url "redis://:password@127.0.0.1:6379/0" \
  --default

Or use explicit fields:

bash <skill-path>/scripts/redis_crud.sh configure \
  --profile local \
  --mode direct \
  --redis-host 127.0.0.1 \
  --redis-port 6379 \
  --redis-db 0 \
  --prompt-redis-password \
  --default

Add --test-connection to verify PING before the profile is saved.

SSH Remote

Use this when the agent should SSH to a server and run the remote redis-cli there. This is best when the server has access to a private Redis instance and REDIS_URL is already present in a remote .env file.

bash <skill-path>/scripts/redis_crud.sh configure \
  --profile prod \
  --mode ssh-remote \
  --ssh-alias app-prod \
  --remote-cwd /server/app \
  --env-file .env \
  --env-key REDIS_URL \
  --readonly \
  --default

The script SSHes to the server, optionally runs cd <remote_cwd>, reads REDIS_URL from the remote .env, and runs redis-cli on the remote host. It must not display the full REDIS_URL.

Use --remote-cwd when the .env file exists only inside an application directory after SSH login. --env-file may be either relative to --remote-cwd, such as .env, or an absolute path.

SSH Tunnel

Use this when the local script should open an SSH tunnel to a private Redis host, then connect locally with redis-cli.

bash <skill-path>/scripts/redis_crud.sh configure \
  --profile staging \
  --mode ssh-tunnel \
  --ssh-host staging.example.com \
  --ssh-user ubuntu \
  --ssh-key ~/.ssh/staging.pem \
  --redis-host 10.0.1.20 \
  --redis-port 6379 \
  --redis-db 0 \
  --prompt-redis-password

List Profiles

bash <skill-path>/scripts/redis_crud.sh list-profiles

The output is redacted.

Remove Profile

bash <skill-path>/scripts/redis_crud.sh remove-profile --profile staging

Read Commands

Ping:

bash <skill-path>/scripts/redis_crud.sh ping --profile prod

Get string value:

bash <skill-path>/scripts/redis_crud.sh get \
  --profile prod \
  --key session:123

Read hash field:

bash <skill-path>/scripts/redis_crud.sh hget \
  --profile prod \
  --key user:123 \
  --field email

Read all hash fields:

bash <skill-path>/scripts/redis_crud.sh hgetall \
  --profile prod \
  --key user:123

Scan keys:

bash <skill-path>/scripts/redis_crud.sh scan \
  --profile prod \
  --pattern "session:*" \
  --count 100

Continue a paginated scan with next_cursor from the previous response:

bash <skill-path>/scripts/redis_crud.sh scan \
  --profile prod \
  --pattern "session:*" \
  --count 100 \
  --cursor 384

Scan until Redis returns cursor 0:

bash <skill-path>/scripts/redis_crud.sh scan \
  --profile prod \
  --pattern "session:*" \
  --count 100 \
  --all

Write Commands

Dry-run SET first:

bash <skill-path>/scripts/redis_crud.sh set \
  --profile staging \
  --key feature:flag \
  --value enabled \
  --ttl 3600

Execute only after explicit confirmation:

bash <skill-path>/scripts/redis_crud.sh set \
  --profile staging \
  --key feature:flag \
  --value enabled \
  --ttl 3600 \
  --execute

Dry-run DEL first:

bash <skill-path>/scripts/redis_crud.sh del \
  --profile staging \
  --key session:123

Execute only after explicit confirmation:

bash <skill-path>/scripts/redis_crud.sh del \
  --profile staging \
  --key session:123 \
  --execute

Dry-run HSET first:

bash <skill-path>/scripts/redis_crud.sh hset \
  --profile staging \
  --key user:123 \
  --field email \
  --value test@example.com

Raw Commands

Use raw commands for read-only commands when the structured commands are too limited:

bash <skill-path>/scripts/redis_crud.sh raw-command \
  --profile prod \
  --command "TTL session:123"

Use repeated --arg values for commands with spaces or complex quoting:

bash <skill-path>/scripts/redis_crud.sh raw-command \
  --profile prod \
  --arg GET \
  --arg "session key with spaces"

Raw write commands require both --execute and --allow-raw-write:

bash <skill-path>/scripts/redis_crud.sh raw-command \
  --profile staging \
  --arg EXPIRE \
  --arg session:123 \
  --arg 3600 \
  --execute \
  --allow-raw-write

Prefer structured commands when they exist. Prefer --arg over --command when values contain spaces or complex shell quoting.

Response Shape

Success responses include:

  • profile
  • mode
  • operation
  • operation-specific fields such as key, field, or ttl
  • dry_run for write previews
  • result
  • lines

Notes

  • Use ssh-remote for production-style access where the server already knows REDIS_URL.
  • For ssh-remote, set --remote-cwd when the .env lives inside a project directory on the remote server.
  • Use ssh-tunnel when Redis is private but commands should run through local redis-cli.
  • Use direct for local or directly reachable Redis.
  • Use configure --test-connection when the user wants to confirm saved connection details before relying on a profile.
  • For --url, the script passes the full URL to redis-cli, so username, password, database, and TLS-style URL forms supported by redis-cli are preserved.
  • ssh-tunnel port checks use nc, lsof, ss, or netstat fallbacks, which keeps the script usable on macOS and Windows shell environments such as Git Bash or WSL.
  • This skill is not a Redis migration or backup tool. Do not use it for broad destructive operations unless the user explicitly asks and approves the risk.

Example Prompts

Chinese

  • "Configure a Redis profile named prod, connect to the server via ssh alias app-prod, after entering /server/app read REDIS_URL from .env, read-only."
  • "Look up session:123 in prod."
  • "Scan keys matching session:* in prod."
  • "Set staging's feature:flag to enabled, TTL 3600, dry-run first."

English

  • "Configure a readonly Redis profile through SSH using the remote REDIS_URL."
  • "Get session:123 using the default Redis profile."
  • "Scan keys matching session:*."
  • "Preview setting a Redis key with a TTL before executing it."