Building a Book Sharing application with Amazon Q CLI
I read a lot, and always have a couple of books on the go at any one time (currently Linchpin by Seth Godin and The Prisoner of Heaven by Carlos Ruiz Zafon. I am always on the lookout for a new book though, and this thread on LinkedIn sparked an idea (check the comments) about building a simple book sharing application that a group of friends might use to share good books they recommend. I had an idea of what I wanted to create: a simple web application that a group of friends could use to create lists of the books they are reading, provide ratings and comments, and then allow them to share and borrow books they might be interested in. I had a couple of hours whilst I was travelling, and wanted to use Amazon Q CLI to build this. Why? I have been slowly switching from VSCode to Zed, and there is no Amazon Q Developer plugin for Zed. I can however, use Amazon Q CLI in the terminal, so this felt like an experiment worth trying to see how I got on with this setup. Building from a strong foundation When I start a greenfield project, I take some time to think about the data model. I have found that this helps shape the output from AI Coding Assistants, providing more consistency and a greater alignment to what I want. This is the prompt I start off with to help shape my idea for a book sharing application. Generate data model for a Book Sharing application that meets the following criteria: A user must have an invite code when they register Users register accounts via email address When a user registers it generates a new invite code for that account The number of users registered from any given invite code is stored with the user profile Users can define an alias (that does not need to be unique) and an optional bio Users will create a new book definition A book definition will have a title and author (mandatory, not unique) A book definition will be owned by the person creating the book definition A book definition will have an ISBN and link to where the book can be purchased (URL) A book definition will allow a number of comments to be added by anyone A book definition will define a recommendation for this book, which will be a sliding scale of 1 (not recommended) to 5 (highly recommended) A book definition will show whether the book is available to borrow (the borrow status) which will be either available or not available A book definition will show who has borrowed a book (it will record their alias) Define the data model in yaml format that will work across different SQL versions Amazon Q CLI did a decent job of creating an initial data model that I can use to bootstrap the building of the application. As I build the code up, this data model will change - there are things that I did not think of which needed to be added (for example, the ability to hide books you might not want to see, or set different categories). That is ok though, as these smaller incremental changes can be managed as long as you have the right building blocks. That is the perfect segway into looking at building blocks, or scaffolds. Scaffolding Scaffolds are markdown documents that live in your project workspace that provide essential context to help your AI Coding Assistants. In my experience, they do a good job at steering the direction of Amazon Q CLI. Amazon Q Developer in the IDE allows you to configure "Rules" files, which are markdown documents that live in a specific directory where you can define these scaffolding rules. You can use the same rules files if you have been using these in Amazon Q Developer, or you can specify them in another file (for example, AmazonQ.md). I created an ".amazonq/rules" directory in my project workspace, and added two files which contain my specific preferences I want Amazon Q CLI to follow. ├── .amazonq │ └── rules │ ├── 1.project-layout-rules.md │ └── 2.project-spec.md We can check that Amazon Q CLI can see these by using the /context command. > /context show

I read a lot, and always have a couple of books on the go at any one time (currently Linchpin by Seth Godin and The Prisoner of Heaven by Carlos Ruiz Zafon. I am always on the lookout for a new book though, and this thread on LinkedIn sparked an idea (check the comments) about building a simple book sharing application that a group of friends might use to share good books they recommend. I had an idea of what I wanted to create: a simple web application that a group of friends could use to create lists of the books they are reading, provide ratings and comments, and then allow them to share and borrow books they might be interested in.
I had a couple of hours whilst I was travelling, and wanted to use Amazon Q CLI to build this. Why? I have been slowly switching from VSCode to Zed, and there is no Amazon Q Developer plugin for Zed. I can however, use Amazon Q CLI in the terminal, so this felt like an experiment worth trying to see how I got on with this setup.
Building from a strong foundation
When I start a greenfield project, I take some time to think about the data model. I have found that this helps shape the output from AI Coding Assistants, providing more consistency and a greater alignment to what I want. This is the prompt I start off with to help shape my idea for a book sharing application.
Generate data model for a Book Sharing application that meets the following criteria:
- A user must have an invite code when they register
- Users register accounts via email address
- When a user registers it generates a new invite code for that account
- The number of users registered from any given invite code is stored with the user profile
- Users can define an alias (that does not need to be unique) and an optional bio
- Users will create a new book definition
- A book definition will have a title and author (mandatory, not unique)
- A book definition will be owned by the person creating the book definition
- A book definition will have an ISBN and link to where the book can be purchased (URL)
- A book definition will allow a number of comments to be added by anyone
- A book definition will define a recommendation for this book, which will be a sliding scale of 1 (not recommended) to 5 (highly recommended)
- A book definition will show whether the book is available to borrow (the borrow status) which will be either available or not available
- A book definition will show who has borrowed a book (it will record their alias)
Define the data model in yaml format that will work across different SQL versions
Amazon Q CLI did a decent job of creating an initial data model that I can use to bootstrap the building of the application. As I build the code up, this data model will change - there are things that I did not think of which needed to be added (for example, the ability to hide books you might not want to see, or set different categories). That is ok though, as these smaller incremental changes can be managed as long as you have the right building blocks. That is the perfect segway into looking at building blocks, or scaffolds.
Scaffolding
Scaffolds are markdown documents that live in your project workspace that provide essential context to help your AI Coding Assistants. In my experience, they do a good job at steering the direction of Amazon Q CLI. Amazon Q Developer in the IDE allows you to configure "Rules" files, which are markdown documents that live in a specific directory where you can define these scaffolding rules.
You can use the same rules files if you have been using these in Amazon Q Developer, or you can specify them in another file (for example, AmazonQ.md). I created an ".amazonq/rules" directory in my project workspace, and added two files which contain my specific preferences I want Amazon Q CLI to follow.
├── .amazonq
│ └── rules
│ ├── 1.project-layout-rules.md
│ └── 2.project-spec.md
We can check that Amazon Q CLI can see these by using the /context command.
> /context show