DEV Community

Cover image for Build your own shell : Codecrafters Edition
Sumit Roy
Sumit Roy

Posted on

Build your own shell : Codecrafters Edition

Dream

Have you ever thought of building your own shell — or anything you use in your daily tasks? It could be an IDE, a simple database, or even a text editor. In this blog, I’ll walk you through the exciting journey of building a shell using the Codecrafters platform. I’ll share why the experience is amazing and why you should absolutely give it a try!

The Challenge

I always wondered how a shell parses configuration files like <shell>.rc and runs both built-in commands and those available in the $PATH. Could I build one myself?

Then came Codecrafters, with their "Build Your Own Shell" challenge — not just a roadmap, but an entire platform designed to verify your implementation and foster collaboration.

Here's what they offer:

  1. A structured roadmap broken into multiple stages.
  2. Each stage comes with detailed instructions to guide your implementation.
  3. Once you complete a stage, you run their test suite to validate your code.
  4. If your solution passes all tests — congratulations, you've completed that stage!
  5. The shell challenge has 8 stages, followed by optional extensions to deepen your learning.

📌 The Codecrafters platform provides an incredibly well-guided and rewarding experience. It’s like a playground for serious builders.

Implementation

The journey begins with something deceptively simple: echo.

Yes, just that.

But implementing echo sets the tone for the entire challenge. You’re immediately faced with choices. Will you write a minimal implementation to pass the test? Or will you craft a modular command resolver that can scale?

This is where your coding craftsmanship shines. The challenge isn't just technical—it's philosophical. You begin questioning your language of choice, its capabilities, and limitations. At times, you'll find yourself diving deep into documentation, searching for the best pattern or idiomatic approach.

Here’s a quick snippet in Python to get started:

import sys

def shell_echo(args):
    print(' '.join(args))

if __name__ == "__main__":
    shell_echo(sys.argv[1:])
Enter fullscreen mode Exit fullscreen mode

Proofs

I know if I don't give you the proof you won't believe me. So here's what I implemented. https://github.com/sroy8091/codecrafters-shell-python. And I got this nice banner after completion:
Completion Banner

Fun fact:

After completing a stage where your shell can run a program given in $PATH, you can submit your code in your own shell 😅

Challenge Link -> https://app.codecrafters.io/courses/shell/introduction
Use my referral link for discounts and perks -> https://app.codecrafters.io/r/happy-donkey-254786

What's next

You may wonder what I am going to build next? Well I took the challenge on building Redis next and I will share more about the experience in the next blog.

Top comments (1)

Collapse
 
evoagentx profile image
EvoAgentX

I like it.