Bootstrap a React app with smol developer
Tags: react, smol, webdev
Published: 2023-09-26 15:18:54

**Written by [Kealan Parr](https://blog.logrocket.com/author/kealanparr/)✏️**

AI has exploded in popularity and technical capacity in recent years, enabling a huge amount of automations, enhancements, and features that feel like the start of a new age. 

One of these paradigms is the idea that AI will eventually do more and more of the work that is currently done by people. Across a wide variety of sectors, AI has the potential to empower, or even replace, workers by doing jobs that can be easily automated. A [recent study in the UK](https://www.bbc.co.uk/news/technology-65102150) estimates that 46 percent of administrative work and 44 percent of legal work could be automated through the use of an AI. 

Artificial intelligence can also be useful for developers. Any element of development work that is monotonous, easily repeatable, or very simple is a prime candidate for AI automation. 

In this article, we’ll investigate the features and capabilities of the smol developer library, created by a developer, to automate routine development tasks. We’ll also walk through a tutorial to demonstrate how to use smol developer to scaffold a basic React app. 

_Jump ahead:_

*   [What is smol developer?](#what-is-smol-developer)
*   [Prerequisites](#prerequisites)
*   [Setting up smol developer](#setting-up-smol-developer)
*   [Bootstrapping a React app](#bootstrapping-react-app)
*   [Creating a browser plugin](#creating-browser-plugin)
*   [Pair programming with smol developer](#pair-programming-with-smol-developer)
*   [smol developer best practices](#smol-developer-best-practices)
    *   [It’s okay to be verbose](#verbose)
    *   [Leverage smol developer for debugging and further development](#leverage-smol-developer-debugging-development)
    *   [Improve your prompts](#improve-prompts)

## What is smol developer?

The [smol developer](https://github.com/smol-ai/developer) AI tool was built by a developer called [Swyx](https://twitter.com/swyx) using ChatGPT. This library is designed to act like a personal, junior developer, performing a huge array of simple, routine tasks as well as some sophisticated tasks. By using a spec that you provide in a prompt, you can even use smol developer to pair program with an AI tool!

> **N.B.**, smol is a common internet term that means "small."

According to the library’s project documentation page, you can use smol developer for a couple of use cases. smol developer will:

*   Scaffold an entire codebase, from a prompt
*   Provide the basic building blocks to embed the library directly inside your own app

The library’s strength is that it is incredibly dynamic. If you‘re using it in your software development lifecycle, it can do so much. 

For example, the [Create React App toolchain is useful for building SPAs and optimizing React apps](https://blog.logrocket.com/getting-started-with-create-react-app/), but it’s a single-shot, one-problem fix. smol developer can do all of that and more; it can solve a host of problems for you. 

To make more sense of this, let’s jump into the tutorial portion of our article and get smol developer to do some work for us!

## Prerequisites

To follow along with this article, you’ll need the following:

*   Python 3 installed
*   pip installed
*   Your [OpenAI API key](https://platform.openai.com/account/api-keys) for the call to ChatGPT (here’s an example key: `sk-SJRknbfXO0mxfrUKjMlKT8BlbkFJsxcFXSzKloIdT6xfkYF6bm`): ![Smol-developer OpenAI API Key](https://blog.logrocket.com/wp-content/uploads/2023/09/smol-developer-openai-api-key.png)
*   A [GPT-4](https://openai.com/gpt-4) subscription (optional). smol developer works much better with GPT-4, which requires a paid subscription ($20 per month as of this writing). The examples from this article will work with GPT-3, but the final result may differ slightly from this article

## Setting up smol developer

There are multiple ways to run smol developer. For the simplicity of this article, let’s follow the easiest option! 

This Git repo approach enables you to clone the repository, bring the Python script up, and then allow smol developer to do your routine work! 

First, enter your API key from OpenAI into your `.env` file:

```shell
OPENAI_API_KEY=sk-SJRknbfXO0mxfrUKjMlKT8BlbkFJsxcFXSzKloIdT6xfkYF6bm
```

Next, you’ll need to run some simple command line instructions:

```shell
git clone https://github.com/smol-ai/developer.git
cd developer
pip install poetry
poetry install
```

> **N.B.**, `poetry` is a dependency and package manager in the Python ecosystem that smol developer uses.

## Bootstrapping a React app <a name="bootstrapping-react-app">

Once you’ve run the above command, you’ll be able to feed prompts directly into the command line if you wish. Unfortunately, 99% of the prompts that are really useful, will end up being longer than what you’d type on the command line. 

To address this problem, smol developer allows you to type a prompt into a basic markdown file, `prompt.md`. 

For example, you could add something like the following to the `prompt.md` file:

> Bootstrap a basic React app for me, with an end result that will display the words "React App created with GPT-4"

Then, you simply invoke the Python script, like so:

```shell
python main.py --prompt prompt.md
```

And, like magic, the repo is created: ![Bootstrapping React App Smol-Developer](https://blog.logrocket.com/wp-content/uploads/2023/09/bootstrapping-react-app-mol-developer.png) This might be the developer's dream! 😉

## Creating a browser plugin <a name="creating-browser-plugin">

To really understand the dynamic nature of smol developer, let’s take a look at a browser plugin that Swyx created to summarize articles. He did not do any coding, he simply prompted smol developer to create the plugin: https://www.youtube.com/watch?v=UCo7YeTy-aE&&ab_channel=swyx smol developer can take care of a lot of the grunt work of development! Even if you just use smol developer to create a starter template, and then you take over and manually edit and enhance the template, that’s still a huge time savings.

## Pair programming with smol developer

When developers are working on a big feature or a whole new set of features, their work is broken down into multiple smaller pieces they need to tackle to ensure the project goes smoothly. 

Let’s say you’re creating a new button for your app. You might break down the work into the following smaller chunks:

*   Creating the button in the frontend
*   Styling the button with CSS to match the designer's specifications
*   Ensuring the button’s click handler calls the backend, to change the user’s profile picture
*   Ensuring the backend selects the profile picture and saves it in the database
*   Ensuring the frontend displays a green thumbs up SVG, indicating that the profile picture change was a success

When you break your software projects down into small, simple steps, smol developer can function like a junior developer and can be entrusted with portions of your project work. 

For example, if you’re building a website to generate random numbers, you could break down the project into smaller problems, solved with prompts. This approach can then help you rapidly deliver something in a much easier way. Some of the prompts might look something like this:

> Write a JavaScript function to generate a random number Write an HTML page with a button that has a click handler attached

If there’s a point in the project when you can’t immediately recall how to do something, instead of searching Google for the answer, your new flow can be to just ask ChatGPT to do it for you or utilize smol developer. 

From time to time, you may still get stuck trying to remember how to pull out a random item from an array. But when you’re paired with an AI, two heads are always better than one!

## smol developer best practices

There are some best practices to follow that will help you ensure you’re getting the most out of this new way of working. Let’s discuss some of them.

### It’s okay to be verbose <a name="verbose">

Some developers seem to be keen to give AI tools the smallest amount of information, concerned that they might overwhelm or confuse the tool. The best prompts are generally those that are well thought out, thoroughly explained, and don’t leave very much for ChatGPT to interpret or assume. 

A great example is the [approximately 100-line prompt](https://github.com/smol-ai/developer/blob/main/prompt.md) that Swyx wrote when he created the browser plugin example we discussed previously.

### Leverage smol developer for debugging and further development <a name="leverage-smol-developer-debugging-development">

If you don’t know how to code, you could reach a point where you feel stuck when working with smol developer. For example, let’s say you use it via prompting to build a new website, but the website keeps crashing when you click on a certain page. 

You can actually use smol developer to debug itself! There are several [examples of debugging prompts](https://github.com/smol-ai/developer/blob/main/prompt.md#debugging-notes) in the `prompt.md` file. 

Let’s say you don’t have the technical proficiency to enhance the starter template that smol developer creates. You could use an approach that Swyx calls [logbook-driven development](https://github.com/smol-ai/developer/blob/main/prompt.md#debugging-notes), where you use additional, increasingly detailed prompts to have smol developer further iterate on and enhance the website.

### Improve your prompts <a name="improve-prompts">

As a developer, there are always parts of an API that we aren’t familiar with, or can’t fully recall. This is why we often end up reading the docs for hours and hours. 

Abstractions crop up all over the place. As a talented software developer, you still can’t know every intricacy of every tool you use. If you did, you‘d still be reading code specs before you ever wrote a single line of code! 

Fortunately, smol developer can do most of the work for you in this new world. If you ever get stuck with smol developer and decide to handle some of the project manually, your energy required to get something "off the ground" will still be much less than developing everything yourself from scratch. 

Just think of all the extra time you’ll have without having to read through the docs in detail just to get the very basics started. Instead, you might choose to just skim the docs to help make your prompts clearer or to unblock something that smol developer is struggling with. 

The clearer and more detailed that you can make your prompts, the better the resulting code generated by smol developer. Here’s an example of a prompt that’s a little too broad for smol developer:

> Write a browser plugin to summarize articles on a webpage

The best prompts are very verbose and detailed. For example, Swyx’s prompt for building a browser plugin is around [131 lines long](https://github.com/smol-ai/developer/blob/main/prompt.md#debugging-notes). It begins like this:

> a Chrome Manifest V3 extension that reads the current page, and offers a popup UI that has the page title+content and a textarea for a prompt (with a default value we specify). When the user hits submit, it sends the page title+content to the Anthropic Claude API along with the up-to-date prompt to summarize it. The user can modify that prompt and re-send the prompt+content to get another summary view of the content.

## Conclusion

In this article, we introduced smol developer, a new AI tool built by and for developers. We investigated using smol developer to bootstrap a React app, looked at an example of using the tool to create a browser plugin, and discussed how it can be used for pair programming. We also reviewed some best practices. 

I hope this article has been useful to you, whether you’re an experienced developer interested in how AI can augment your knowledge or a total newbie looking to understand how to use AI to simplify the process of creating your first software program.

---

## Get set up with LogRocket's modern React error tracking in minutes:

1. Visit https://logrocket.com/signup/ to get an app ID.
2. Install LogRocket via NPM or script tag. `LogRocket.init()` must be called client-side, not server-side.

NPM:
```bash
$ npm i --save logrocket 

// Code:

import LogRocket from 'logrocket'; 
LogRocket.init('app/id');
```
Script Tag:
```javascript
Add to your HTML:

<script src="https://cdn.lr-ingest.com/LogRocket.min.js"></script>
<script>window.LogRocket && window.LogRocket.init('app/id');</script>
```

3.(Optional) Install plugins for deeper integrations with your stack:
*   Redux middleware
*   ngrx middleware
*   Vuex plugin

[Get started now](https://lp.logrocket.com/blg/signup)