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_URLexists on a server, such as a remote.envfile 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>.jsonby default
Safety Rules
- Never save Redis credentials in this repository.
- Use
~/.config/redis-crud/profiles/<profile>.conffor saved profiles. - Do not print passwords or full Redis URLs; use
list-profilesfor 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
--executeonly after explicit user confirmation. - Raw write commands require both
--executeand--allow-raw-write. readonlyprofiles must not be used for write commands.- Prefer structured commands over
raw-command. - Prefer repeated
raw-command --argvalues when keys or values contain spaces;--commandremains available only for simple space-separated commands.
What This Skill Needs
bash- local
redis-clifordirectandssh-tunnelprofiles sshforssh-tunnelandssh-remoteprofiles- remote
bashandredis-cliforssh-remoteprofiles - one of
nc,lsof,ss, ornetstatfor 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:
profilemodeoperation- operation-specific fields such as
key,field, orttl dry_runfor write previewsresultlines
Notes
- Use
ssh-remotefor production-style access where the server already knowsREDIS_URL. - For
ssh-remote, set--remote-cwdwhen the.envlives inside a project directory on the remote server. - Use
ssh-tunnelwhen Redis is private but commands should run through localredis-cli. - Use
directfor local or directly reachable Redis. - Use
configure --test-connectionwhen the user wants to confirm saved connection details before relying on a profile. - For
--url, the script passes the full URL toredis-cli, so username, password, database, and TLS-style URL forms supported byredis-cliare preserved. ssh-tunnelport checks usenc,lsof,ss, ornetstatfallbacks, 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
- "配置一个 Redis profile,名字叫 prod,通过 ssh alias app-prod 到服务器,进入 /server/app 后读取 .env 的 REDIS_URL,只读。"
- "查 prod 里的 session:123。"
- "扫描 prod 里 session:* 的 key。"
- "把 staging 的 feature:flag 设置为 enabled,TTL 3600,先 dry-run。"
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."