The CodeCrafters challenge authors program is invite-only. Interested in building CodeCrafters challenge? Write to us at hello@codecrafters.io.

Stage instructions are the heart of a CodeCrafters challenge. Remember that most learners will be new to both the CodeCrafters platform and your challenge itself, so it’s important to write clear, concise and helpful stage instructions.

Structure

We recommend following this structure when writing stage instructions:

  1. Hook: A short sentence that describes what the user will do in this stage.
  2. Explanation: A longer explanation of the concepts involved in this stage, and what the user needs to implement.
  3. Tests: A clear description of how the user’s program will be tested, and what the expected output/behaviour is.
  4. Notes (optional): Any additional notes or tips that might be helpful for the user.

Example

Here’s an example from the Redis challenge:

In this stage, you’ll add support for the TYPE command.

The TYPE command

The TYPE command returns the type of value stored at a given key.

It returns one of the following types: string, list, set, zset, hash, and stream.

Here’s how it works:

$ redis-cli set some_key foo
"OK"
$ redis-cli type some_key
"string"

If a key doesn’t exist, the return value will be “none”.

$ redis-cli type missing_key
"none"

The return value is encoded as a simple string.

Tests

The tester will execute your program like this:

$ ./spawn_redis_server.sh

It’ll then send a SET command to your server.

$ redis-cli set some_key foo

It’ll then send a TYPE command to your server.

$ redis-cli type some_key

Your server should respond with +string\r\n, which is string encoded as a RESP simple string.

It’ll then send another TYPE command with a missing key.

$ redis-cli type missing_key

Your server should respond with +none\r\n, which is none encoded as a RESP simple string.

Notes

  • For now, you only need to handle the “string” and “none” types. We’ll add support for the “stream” type in the next stage.