From ca6042f62a6f4a5d1451bdbece3ba247d1c892e4 Mon Sep 17 00:00:00 2001 From: "aman.shrivas" Date: Fri, 6 Mar 2026 13:26:17 +0000 Subject: [PATCH] Update skill creation for Postgres --- skills/postgres/resources/ai_rules.md | 36 +++++++++++++++++++ .../postgres/resources/setup_instructions.md | 28 +++++++++++++++ skills/postgres/scripts/install_postgres.ps1 | 12 +++++++ skills/postgres/scripts/install_postgres.sh | 14 ++++++++ skills/postgres/skill.md | 22 ++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 skills/postgres/resources/ai_rules.md create mode 100644 skills/postgres/resources/setup_instructions.md create mode 100644 skills/postgres/scripts/install_postgres.ps1 create mode 100644 skills/postgres/scripts/install_postgres.sh create mode 100644 skills/postgres/skill.md diff --git a/skills/postgres/resources/ai_rules.md b/skills/postgres/resources/ai_rules.md new file mode 100644 index 00000000..4e1b28d6 --- /dev/null +++ b/skills/postgres/resources/ai_rules.md @@ -0,0 +1,36 @@ +# AI Rules for the PostgreSQL Project + +## 1. Project Overview + +This project provides a self-contained, reproducible PostgreSQL development environment using Nix. It is designed to be a ready-to-use database starter with a pre-defined schema and sample data. + +The key characteristics are: + +- **Automated Setup:** The environment is fully automated by the `.idx/dev.nix` file. It starts a PostgreSQL 16 server, creates a database, and initializes it. +- **Database Details:** + - **Database Name:** `youtube` + - **User:** `user` + - **Password:** `mypassword` +- **Pre-configured Tools:** The environment includes the `sqltools` and `sqltools-driver-pg` VS Code extensions for immediate database interaction. + +## 2. Key Files + +When providing assistance, be aware of the following files: + +- **`create.sql`**: Defines the database schema (tables, columns, etc.). This is the source of truth for the database structure. +- **`example.sql`**: Contains sample data that is inserted into the database after the schema is created. Useful for demonstrating queries. +- **`.idx/dev.nix`**: The core Nix file that defines the entire development environment, including services, packages, and startup scripts. Avoid suggesting manual installation of packages that can be managed here. + +## 3. Development Environment + +- **Nix-Managed:** The environment is controlled by Nix. Do not suggest using `apt`, `brew`, or other system-level package managers. Dependencies like `postgresql` are managed through the `dev.nix` file. +- **SQLTools:** The workspace is pre-configured with SQLTools. Encourage users to leverage this extension for running queries, browsing the schema, and managing the database directly from the IDE. +- **Connection String:** The `POSTGRESQL_CONN_STRING` environment variable is available for applications that need to connect to the database. + +## 4. Interaction Guidelines + +- Assume the user is familiar with SQL but may be new to this Nix-based, automated setup. +- When generating SQL queries, tailor them to the schema defined in `create.sql` (e.g., query the `videos` table). +- If a user wants to modify the database schema, guide them to edit the `create.sql` file. Remind them that for the changes to take effect in a new workspace, the setup script must be re-run (which happens automatically on creation). For an existing workspace, they may need to apply the changes manually using SQLTools. +- Proactively suggest using the integrated SQLTools for database interaction instead of external clients. +- If the user asks about connection details, refer them to the pre-set database name (`youtube`), user (`user`), and password (`mypassword`). diff --git a/skills/postgres/resources/setup_instructions.md b/skills/postgres/resources/setup_instructions.md new file mode 100644 index 00000000..44780a69 --- /dev/null +++ b/skills/postgres/resources/setup_instructions.md @@ -0,0 +1,28 @@ +# Postgres Workspace Setup Instructions + +This skill automates the entire setup of a new PostgreSQL database environment. There are no manual installation steps required. + +--- + +## 1. Create the Database Project + +When you run this skill, you will be prompted for a `Project Name`. This name will be used to create a new directory for your database project. + +The skill will then automatically perform the following actions: + +- **Scaffold the Project:** It copies a pre-configured set of files into your new project directory. +- **Configure the Environment:** A file at `.idx/dev.nix` is included, which tells IDX to automatically: + - Start a PostgreSQL 16 server. + - Create a database named `youtube`. + - Create a user named `user` with the password `mypassword`. + - Initialize the database schema by running `create.sql`. + - Populate the database with sample data by running `example.sql`. +- **Set Environment Variables:** It configures the `POSTGRESQL_CONN_STRING` environment variable so you can connect to your database instantly. + +--- + +## 2. Using Your Database + +Once the skill is finished, your PostgreSQL database is ready to use immediately. + +No further setup is required. You can connect to the database using the provided connection string or use the integrated SQLTools within the IDE. diff --git a/skills/postgres/scripts/install_postgres.ps1 b/skills/postgres/scripts/install_postgres.ps1 new file mode 100644 index 00000000..d7800ea4 --- /dev/null +++ b/skills/postgres/scripts/install_postgres.ps1 @@ -0,0 +1,12 @@ +# Prompt the user for a project name. +$ProjectName = Read-Host -Prompt "Enter the project name (default: my-postgres-project)" + +# If no project name is entered, use the default. +if ([string]::IsNullOrWhiteSpace($ProjectName)) { + $ProjectName = "my-postgres-project" +} + +# Copy the pre-configured postgres app template to the new project directory. +Copy-Item -Path "postgres/app" -Destination $ProjectName -Recurse -Force + +Write-Host "PostgreSQL project '$ProjectName' created successfully." diff --git a/skills/postgres/scripts/install_postgres.sh b/skills/postgres/scripts/install_postgres.sh new file mode 100644 index 00000000..6d27909f --- /dev/null +++ b/skills/postgres/scripts/install_postgres.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Prompt the user for a project name. +read -p "Enter the project name (default: my-postgres-project): " projectName + +# If no project name is entered, use the default. +if [ -z "$projectName" ]; then + projectName="my-postgres-project" +fi + +# Copy the pre-configured postgres app template to the new project directory. +cp -r postgres/app/ "$projectName" + +echo "PostgreSQL project \'"$projectName"\' created successfully." diff --git a/skills/postgres/skill.md b/skills/postgres/skill.md new file mode 100644 index 00000000..5362657e --- /dev/null +++ b/skills/postgres/skill.md @@ -0,0 +1,22 @@ +--- +name: postgres +description: Creates a new PostgreSQL database project using a pre-configured development environment with custom AI rules. +--- + +## When to Use This Skill + +Use this skill when the user wants to create a new, ready-to-use PostgreSQL database environment. The skill scaffolds a complete project with a running database server, a pre-defined schema, and example data. + +## Instructions + +1. **Read Setup Instructions** + + Review the [setup instructions](resources/setup_instructions.md) to understand how the project is initialized. + + *Action: Read `resources/setup_instructions.md`.* + +2. **Create the Project** + + This skill uses a script to create the project. The script will copy the necessary files and set up the initial project structure. + + *Action: `run_terminal_command(command='bash skills/postgres/scripts/install_postgres.sh', windowsCommand='powershell -File skills/postgres/scripts/install_postgres.ps1')`.*