This is the actual wire protocol Redis's own networking.c and every client library (redis-py, node-redis, Jedis) encode and decode on every single command, prized precisely because a simple state machine can parse it without a formal grammar. redis-cli itself is nothing more than a RESP encoder wrapped around stdin/stdout, which is what you're building a miniature version of here.