Creates and initializes a new microservice that provides CRUD operations to a SQL database such as MySQL, Postgres or Microsoft SQL Server. Use when explicitly asked by the user to create a new SQL or CRUD microservice to persist an object.
CRITICAL: Do NOT explore or analyze other microservices unless explicitly instructed to do so. The instructions in this skill are self-contained to this microservice.
IMPORTANT: MyNoun, MyNounKey, mynoun, and mynounapi are placeholders for the actual object, its key, directory, and API package of the microservice.
IMPORTANT: Do not remove the Example field or code related to it from the code since it is required by various tests.
IMPORTANT: Read .claude/rules/sequel.txt for SQL CRUD conventions before proceeding.
Copy this checklist and track your progress:
Creating a new microservice:
- [ ] Step 1: Determine the Noun and Hostname
- [ ] Step 2: Create a Directory Structure for the New Microservice
- [ ] Step 3: Copy Template Files
- [ ] Step 4: Find and Replace
- [ ] Step 5: Add to Main App
- [ ] Step 6: Add to config file
- [ ] Step 7: Housekeeping
- [ ] Step 8: Propose Object Fields
Determine the singular noun representing the object being persisted, for example, "User", "Notebook", "Sales Order", etc. In subsequent steps, mynoun is used as a placeholder for the lowercase form of this noun with spaces removed (e.g. user, notebook, salesorder).
Determine the hostname. The hostname is how this microservice will be addressable. It must be unique across the application. Use reverse domain notation based on the module path, up to and including the name of the project. For example, if the module path is github.com/mycompany/myproject/some/path/mynoun, set the hostname to mynoun.path.some.myproject. Only letters a-z, numbers 0-9, hyphens - and the dot . separator are allowed in the hostname.
Each microservice must be placed in a separate directory. Create a new directory for the new microservice.
For the directory name, use mynoun with only lowercase letters a through z, for example, user, notebook or salesorder.
In smaller projects, place the new directory under the root directory of the project. In larger projects, consider using a nested directory structure to group similar microservices together.
mkdir -p mynoun
The .claude/skills/sequel/add-microservice/busstop directory contains the canonical implementation code for the noun BusStop. Use cp or a similar tool to copy verbatim the content of the busstop template directory to the microservice's directory mynoun. Do not read the files.
The directory structure should look like this.
myproject/
└── mynoun/
├── busstopapi/
└── resources/
IMPORTANT: File names in the following steps are relative to the new microservice directory mynoun, unless indicated otherwise.
Rename the directory busstopapi to mynounapi.
The directory structure should look like this.
myproject/
└── mynoun/
├── mynounapi/
└── resources/
CRITICAL: This step must be scoped to the microservice directory only. Do not perform it on the project root.
Use sed or a similar tool to perform the following case-sensitive find-and-replace operations on ALL files in the microservice directory. Do not read the files.
Perform these replacements in order:
github.com/microbus-io/fabric/busstop with the package path of this microservice, e.g. github.com/mycompany/myproject/mynounbusstopapi with the name of the API directory mynounapibusstop.hostname with the hostname of this microserviceBusStop with the singular noun of this microservice in PascalCase, i.e. MyNounbus stops with the plural noun of this microservice in lower case (with spaces between words), i.e. my nounsbus stop with the singular noun of this microservice in lower case (with spaces between words), i.e. my nounbusstop with the singular noun of this microservice in lowercase (no spaces between words), i.e. mynounbus_stop with the singular noun of this microservice in snake_case, i.e. my_nounbus-stop with the singular noun of this microservice in kebab-case, i.e. my-noun_CIPHER_KEY_____________________ with a unique 32-character random base64 string (characters A-Z, a-z, 0-9, +, /)_CIPHER_NONCE___________________ with a 32-character random base64 string (characters A-Z, a-z, 0-9, +, /)_SEQUENCE_ with an 8-character random hexadecimal stringRun go fmt on the microservice directory to reformat the Go source files.
Find main/main.go relative to the project root. Add the new microservice to the app in the main function. Add the appropriate import statement at the top of the file.
import (
// ...
"github.com/mycompany/myproject/mynoun"
)
func main() {
// ...
app.Add(
// HINT: Add solution microservices here
mynoun.NewService(),
)
// ...
}
Look for config.local.yaml at the root of the project. If the file does not exist, create it.
If a value already exists for SQLDataSourceName under all in config.local.yaml, skip the remainder of this step.
Add the data source name secrets under all.