Screenshot-Driven Development – DEV Community

Screenshot-Driven Development – DEV Community


I’m a developer at heart, so when I’m working on a personal project, the hardest part isn’t writing code—it’s making design decisions. I recently built a calendar user interface. I wanted to enhance its visual appeal, so I researched UI design trends like “glassmorphism” and “claymorphism.”

However, I didn’t want to spend hours implementing the CSS for each design trend, so I developed a faster approach: screenshot-driven development. I used an open source developer agent called Goose to transform my user interfaces quickly.



My original calendar:

Screenshot 2024-11-15 at 4.08.13 AM



Goose prototyped the designs below:

Screenshot 2024-11-15 at 4.46.23 AM

In this blog post, I’ll show you how to quickly prototype design styles by letting Goose handle the CSS for you.

💡 Note: Your results might look different from my examples – that’s part of the fun of generative AI! Each run can produce unique variations of these design trends.



Get Started with Screenshot-Driven Development



Step 1: Create your UI

Let’s create a basic UI to experiment with. Create an index.html file with the code below:




    
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            background: linear-gradient(45deg, #6e48aa, #9c27b0);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }

        .calendar {
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.1);
            width: 400px;
            padding: 20px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 20px;
            border-bottom: 2px solid #f0f0f0;
        }

        .month {
            font-size: 24px;
            font-weight: 600;
            color: #1a1a1a;
        }

        .days {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 10px;
            margin-top: 20px;
            text-align: center;
        }

        .days-header {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 10px;
            margin-top: 20px;
            text-align: center;
        }

        .days-header span {
            color: #666;
            font-weight: 500;
            font-size: 14px;
        }

        .day {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            font-size: 14px;
            color: #333;
            cursor: pointer;
            transition: all 0.2s;
        }

        .day:hover {
            background: #f0f0f0;
        }

        .day.today {
            background: #9c27b0;
            color: white;
        }

        .day.inactive {
            color: #ccc;
        }
    


    
class="calendar">
class="header">

class="month">November 2024

class="days-header"> Sun Mon Tue Wed Thu Fri Sat

class="days">

class="day inactive">27

class="day inactive">28

class="day inactive">29

class="day inactive">30

class="day inactive">31

class="day">1

class="day">2

class="day">3

class="day">4

class="day">5

class="day">6

class="day">7

class="day">8

class="day">9

class="day">10

class="day">11

class="day">12

class="day">13

class="day today">14

class="day">15

class="day">16

class="day">17

class="day">18

class="day">19

class="day">20

class="day">21

class="day">22

class="day">23

class="day">24

class="day">25

class="day">26

class="day">27

class="day">28

class="day">29

class="day">30

Enter fullscreen mode

Exit fullscreen mode

Once saved, open the file in your browser. You should see a calendar!



Step 2: Install Goose

brew install pipx
pipx ensurepath
pipx install goose-ai
Enter fullscreen mode

Exit fullscreen mode



Step 3: Start a session

goose session start
Enter fullscreen mode

Exit fullscreen mode



Bring your own LLM

Goose will prompt you to set up your API key when you first run this command. You can use various LLM providers like OpenAI or Anthropic

export OPENAI_API_KEY=your_api_key
# Or for other providers:
export ANTHROPIC_API_KEY=your_api_key
Enter fullscreen mode

Exit fullscreen mode



Step 4: Enable the Screen Toolkit

Goose uses toolkits to extend its capabilities. The screen toolkit lets Goose take and analyze screenshots.

To enable the screen toolkit, add it to your Goose profile at ~/.config/goose/profiles.yaml.

Your configuration might look slightly different depending on your LLM provider preferences.

default:
  provider: openai
  processor: gpt-4o
  accelerator: gpt-4o-mini
  moderator: truncate
  toolkits:
  - name: developer
    requires: {}
  - name: screen
    requires: {}
Enter fullscreen mode

Exit fullscreen mode



Step 5: Prompt Goose to screenshot your UI

Goose analyzes your UI through screenshots to understand its structure and elements. In your Gooses session, prompt Goose to take a screenshot by specifying which display your UI is on:

Take a screenshot of display(1)  
Enter fullscreen mode

Exit fullscreen mode

The display number is required – use display(1) for your main monitor or display(2) for a secondary monitor.

Upon success, Goose will run a screencapture command and save it as a temporary file.



Step 6: Prompt Goose to transform your UI

Now, you can ask Goose to apply different design styles. Here are some of the prompts I gave Goose and the results it produced:



Glassmorphism

Apply a glassmorphic effect to my UI
Enter fullscreen mode

Exit fullscreen mode

Screenshot 2024-11-15 at 4.34.21 AM



Neumorphism

Apply neumorphic effects to my calendar and the dates
Enter fullscreen mode

Exit fullscreen mode

Screenshot 2024-11-15 at 4.40.35 AM



Claymorphism

Please replace with a claymorphic effect
Enter fullscreen mode

Exit fullscreen mode

Screenshot 2024-11-15 at 4.41.48 AM



Brutalism

Apply a brutalist effect please
Enter fullscreen mode

Exit fullscreen mode

Screenshot 2024-11-15 at 4.42.54 AM



Learn More

Developing user interfaces is a blend of creativity and problem-solving. And I love that using Goose gives me more time to focus on creativity rather than wrestling with CSS for hours.

Beyond prototyping, Goose’s ability to analyze screenshots can help developers identify and resolve UI bugs.

If you’re interested in learning more, check out the Goose repo and join our Discord community.



Video Demo

Here’s a video version of this blog post




Source link

Leave a Reply

Your email address will not be published. Required fields are marked *