Developer Utilities with Q (Docstrings, README, etc.)
Gavin Rose

Gavin Rose @scarabdata

About: Father, husband, and data geek.

Location:
Columbia, Missouri, USA
Joined:
May 4, 2025

Developer Utilities with Q (Docstrings, README, etc.)

Publish Date: May 10
13 0

This is a submission for the Amazon Q Developer "Quack The Code" Challenge: Crushing the Command Line

What I Built

Dreading docstrings? Tired of writing boilerplate README files? Wish you could automate those tedious development tasks? Meet duq CLI (Developer Utility with Q) - a command-line tool that supercharges your development workflow by leveraging Amazon Q to handle the boring stuff.

duq CLI wraps the Amazon Q CLI with specialized prompt templates to automate common development tasks like:

  • Generating comprehensive README files for your projects
  • Adding proper docstrings to your code files
  • Creating test cases for your functions
  • Suggesting code refactoring improvements
  • Performing security analysis on your codebase

The best part? It maintains a backup system that lets you revert the most recent changes made with the duq CLI with a simple command, giving you the confidence to experiment with AI-powered code improvements.

Demo

Here's a quick example of how duq CLI can transform your workflow:
https://imgur.com/a/duq-duq-goose-32QeSBX

# Generate a README for your project
duq document ./my-project

# Add docstrings to a file
duq docstrings ./src/utils.js

# Generate test cases
duq test ./src/api.js

# Chain commands together
duq chain ./src/models.js "refactor,docstrings,test"

# Oops! Changed your mind? Revert the changes
duq revert
Enter fullscreen mode Exit fullscreen mode

Code Repository

https://github.com/scarab-data/duq-cli
or
try it for yourself by running npm install -g duq-cli

How I Used Amazon Q Developer

Amazon Q Developer was the secret sauce that made duq CLI possible. Aside from Amazon Q being the brains behind the operation, it was also a valuable asset in creating the CLI tool.

To test the efficacy of the idea, I thought it important to consider prompt engineering when initially speaking with Amazon Q.
Short or rushed prompts such as...
q chat "create a readme"
Returned responses like...
Q: I'd be more than happy to assist you in creating a README for your project. Please share the path to your project so that I can get started!
Continuing on the path of chaos...
Me: just do it
Q was able to handle this hasty response with ease, and began scanning through the directory in which the chat was started. Due to lack of instruction and poor prompting, Q wound up generating a README that was seemingly perfect and detailed. Upon further inspection, it turned out Q had hallucinated a file structure that didn't exist within the directory - or anywhere on the computer for that matter.

README with hallucinations

It also seemed as if just because the word 'test' was in the directory name, Q incorrectly assumed that the whole project was for testing, when in reality, it was just a safe place to test out the duq CLI, that is, until duq revert was implemented.

Prompt engineering is definitely an important part of getting what you want out of any AI, and even more so with programming, it is just as important to give context. This is where the duq CLI really helps Amazon Q shine! Certain duq commands such as README take in a directory path, or if none is given, it will analyze the current directory. It feeds information to Q and gives it that ever-so-important context.

One important piece of insight I gained was that Amazon Q excels at understanding context and generating appropriate responses when given well-structured prompts. By designing my CLI to provide rich context (file contents, directory structures) along with clear instructions, I was able to get remarkably useful and consistent outputs.

Comments 0 total

    Add comment