This is a submission for the Amazon Q Developer "Quack The Code" Challenge: Crushing the Command Line
What I Built
Meet ScriptSmith – AI-Powered Automation CLI a command-line tool that uses Amazon Q Developer to automatically generate scripts from natural language prompts, automating repetitive development tasks.
ScriptSmith, a powerful Python CLI tool designed to bridge the gap between natural language task descriptions and automated script generation. This tool is crafted as a streamlined solution for developers, data scientists, and DevOps engineers looking to automate their workflows without manually crafting complex scripts.
ScriptSmith integrates directly with Amazon Q, a cutting-edge AI model for code generation, and Supabase, a scalable backend for task management and data logging. With just a simple natural language prompt, users can generate production-ready scripts tailored to their specific needs.
The setup process is straightforward, guiding users through the configuration of Supabase credentials. It intelligently checks for existing Amazon Q sessions, reducing redundant logins and ensuring a seamless experience. Users can create, list, and run tasks directly from the command line, storing each task in a structured database for future reference.
What sets ScriptSmith apart is its focus on simplicity and extensibility. It abstracts away the complexities of AI code generation and task management, offering a plug-and-play experience for users who may not be deeply familiar with the underlying technologies. The project is designed to be easily deployable as a pip package, making it accessible across a wide range of environments.
Demo
ScriptSmith is now available as a PyPi library, making it easy for anyone to install and use. Simply run the following command to get started:
pip install scriptsmith
Once installed, you can use the scriptsmith CLI to create, list, and run tasks directly from your terminal. This seamless integration with Amazon Q Developer allows you to convert natural language prompts into actionable scripts with just a few commands.
For a quick demo, you can run:
scriptsmith --help
scriptsmith setup
scriptsmith create-task "Generate a Python script to scrape a website"
scriptsmith list-tasks
scriptsmith run-task 1
Code Repository
How I Used Amazon Q Developer
I integrated Amazon Q Developer into ScriptSmith to leverage its advanced AI capabilities for generating scripts from natural language prompts. The goal was to simplify the process of translating human instructions into executable code, making it accessible to both technical and non-technical users.
The integration involved a few key steps:
Authentication and Setup:
To ensure a seamless experience, I incorporated a subprocess call to q login for user authentication, automatically selecting the “Use for Free with Builder ID” option. This approach avoids manual intervention and keeps the setup process smooth.Task Management:
I designed ScriptSmith to fetch task descriptions from a Supabase database, which are then passed to the Amazon Q CLI as prompts. This structure allows for easy task creation, listing, and execution, all managed through a simple, intuitive command-line interface.Real-time Script Generation:
When a user runs a task, ScriptSmith invokes the Amazon Q CLI using the q chat command. It captures the generated script, along with any errors, and logs the output back to the database for future reference. This ensures transparency and traceability of every script generated.Error Handling and Resilience:
I included robust error handling to manage potential issues with Amazon Q API responses, ensuring that the tool remains reliable even when external services experience disruptions.
Overall, integrating Amazon Q Developer transformed ScriptSmith into a powerful, AI-driven automation tool, providing users with a highly efficient way to convert natural language into actionable code.