Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions skills/create-blazor-app/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: create-blazor-app
description: Creates a new Blazor Server App and installs custom AI rules.
inputs:
- id: workspace_name
name: Workspace Name
type: string
description: The name of the folder for the new project
---

## When to Use This Skill

Use this skill when the user wants to create a new Blazor project and wants the project configured with custom AI rules.

## Instructions

1. **Read Setup Instructions**
Review the [setup instructions](resources/setup_instructions.md) to understand how to initialize the project and install dependencies.

*Action:* Read `resources/setup_instructions.md`.

2. **Execute Setup**
Follow the steps outlined in `resources/setup_instructions.md` to:
- Create the Blazor project (using the `workspace_name` input).
- Create the `.agents/rules/dotnet.md` file using the content from `resources/ai_rules.md`.
- Ensure the `.agents/rules/` directory exists.

3. **Final Verification**
Check that:
- A `.csproj` file exists in the new project.
- `.agents/rules/dotnet.md` exists.
- `Program.cs` and a `Components` directory exist.
42 changes: 42 additions & 0 deletions skills/create-blazor-app/resources/ai_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Gemini AI Rules for .NET Projects

## 1. Persona & Expertise

You are an expert .NET developer, proficient in C# and the .NET ecosystem. You have experience building a wide range of applications, from web APIs with ASP.NET Core to desktop and mobile apps. You are familiar with modern .NET features, including LINQ, async/await, and dependency injection. You write clean, performant, and maintainable code, following Microsoft's official C# coding conventions.

## 2. Project Context

This is a .NET project, which could be a web application (ASP.NET Core, Blazor), a web API, a console application, or a library. The project uses the .NET CLI for building, testing, and managing dependencies. The code is organized into solutions (`.sln`) and projects (`.csproj`), following standard .NET conventions.

## 3. Development Environment

- The development environment is expected to have the .NET SDK installed.
- To run the application, use `dotnet watch` for web apps (which provides hot reload) or `dotnet run` for console apps. The command is usually executed from the project directory.
- Web applications are typically served on `http://localhost:5000` or `https://localhost:5001`. The exact URL is specified in the `Properties/launchSettings.json` file.

## 4. Coding Standards & Best Practices

### C# Coding Conventions
- **Naming Conventions:** Follow the Microsoft C# naming conventions (e.g., `PascalCase` for classes, methods, and properties; `camelCase` for local variables).
- **Layout Conventions:** Use the default Visual Studio formatting for code layout.
- **Commenting Conventions:** Use XML documentation comments (`///`) for public APIs to enable IntelliSense.

### .NET Best Practices
- **Dependency Injection (DI):** Use the built-in DI container to manage dependencies. Register services in `Program.cs`.
- **Configuration:** Use the modern configuration system with `appsettings.json` and environment variables. Access configuration via `IConfiguration`.
- **Logging:** Use the built-in logging framework (`ILogger`).
- **Async/Await:** Use `async` and `await` for I/O-bound operations to improve scalability and responsiveness.

### Blazor Specifics
- **Components:** Build UI with Razor components (`.razor` files).
- **Data Binding:** Use the `@bind` attribute for two-way data binding.
- **Routing:** Use the `@page` directive to define routes for components.
- **Event Handling:** Use `@onclick`, `@onchange`, etc., to handle UI events.

## 5. Interaction Guidelines

- Assume the user is familiar with C# and object-oriented programming but may be new to some .NET Core features.
- When generating code, provide explanations for .NET-specific concepts like dependency injection, middleware, and the configuration system.
- If a request is ambiguous, ask for clarification on the project type (e.g., Blazor, web API, console app).
- When suggesting NuGet packages, explain their purpose and how to add them using `dotnet add package <PACKAGE_NAME>`.
- Remind the user to run `dotnet restore` after modifying the project file (`.csproj`) to fetch new dependencies.
65 changes: 65 additions & 0 deletions skills/create-blazor-app/resources/setup_instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Blazor App Workspace Setup Instructions

Follow these steps to initialize the workspace.

## 1. Install prerequisites (.NET SDK)

This skill requires the .NET 8 SDK.

### 1.1 Verify
Run:
- `dotnet --version`

If the command works and the version is 8.0.0 or higher, go to **Step 2**.

### 1.2 Install automatically from official .NET downloads (recommended)
Use the provided prereq installer script to install the .NET SDK.

Run ONE of the following depending on your OS:

#### Windows (PowerShell)
Run:
- `powershell -ExecutionPolicy Bypass -File "scripts/install_dotnet_official.ps1"`

Then restart your terminal session and verify: `dotnet --version`

#### macOS / Linux (bash)
Run:
- `bash "scripts/install_dotnet_official.sh"`

Then restart your shell session and verify: `dotnet --version`

> Note: The script may require `sudo` for system-wide installation.

---

## 2. Create the project

Set your workspace name:
- `WS_NAME="<workspace_name>"`

Then scaffold the Blazor app:
```bash
dotnet new blazor -o "$WS_NAME"
```

## 3. Install dependencies

Change into the project directory:
```bash
cd "$WS_NAME"
```
The `dotnet new` command automatically restores dependencies. If you need to restore them again later, you can run `dotnet restore`.

## 4. Configure Agents Rules

Create the file `.agents/rules/dotnet.md` inside the new workspace directory.

Copy the content from `resources/ai_rules.md`.

## 5. Run the server

From inside your project directory, run:
```bash
dotnet watch
```
64 changes: 64 additions & 0 deletions skills/create-blazor-app/scripts/install_dotnet_official.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Installs the latest .NET 8 SDK from official releases (user-local install).
# - Checks if .NET 8+ is already installed.
# - Downloads official installer script.
# - Installs to %USERPROFILE%\.dotnet_sdk
# - Adds to user PATH (no admin required)
# - Prompts to restart terminal / Antigravity

$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest

function Get-MajorVersion([string]$v) {
$v = $v.Trim()
return [int]($v.Split(".")[0])
}

# If .NET SDK already installed and >= 8, do nothing.
try {
$existing = & dotnet --version 2>$null
if ($LASTEXITCODE -eq 0) {
$major = Get-MajorVersion $existing
if ($major -ge 8) {
Write-Host ".NET SDK is already installed ($existing). No action needed."
exit 0
}
Write-Host ".NET SDK detected ($existing) but < 8; proceeding to install latest .NET 8 SDK."
}
} catch {
# dotnet not found
}

$InstallDir = Join-Path $env:USERPROFILE ".dotnet_sdk"
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null

$InstallScriptUrl = "https://dot.net/v1/dotnet-install.ps1"
$InstallScriptPath = Join-Path $InstallDir "dotnet-install.ps1"

Write-Host "Downloading dotnet-install.ps1 to $InstallScriptPath"
Invoke-WebRequest -Uri $InstallScriptUrl -OutFile $InstallScriptPath

Write-Host "Installing .NET 8 SDK to $InstallDir"
& $InstallScriptPath -Channel 8.0 -InstallDir $InstallDir -NoPath

# Add to user PATH if not present
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (-not $userPath) { $userPath = "" }

$already = $userPath.Split(";") | Where-Object { $_.Trim() -ieq $InstallDir }
if (-not $already) {
$newUserPath = ($InstallDir + ";" + $userPath).TrimEnd(";")
[Environment]::SetEnvironmentVariable("Path", $newUserPath, "User")
Write-Host "Added .NET SDK to user PATH: $InstallDir"
} else {
Write-Host ".NET SDK path already present in user PATH."
}

# Also update current session PATH
$env:Path = $InstallDir + ";" + $env:Path

Write-Host "Installed .NET 8 SDK"
Write-Host "Verify in this session:"
& dotnet --version

Write-Host ""
Write-Host "Restart your terminal / Antigravity session so PATH updates fully."
77 changes: 77 additions & 0 deletions skills/create-blazor-app/scripts/install_dotnet_official.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail

# Installs the latest .NET 8 SDK from official releases (user-local install).
# - Checks if .NET 8+ is already installed.
# - Downloads official installer script.
# - Installs under ~/.dotnet_sdk
# - Updates shell profile PATH (bash/zsh/profile)
# - Prompts restart

need_cmd() { command -v "$1" >/dev/null 2>&1; }

# Check if dotnet is installed and version is >= 8
if need_cmd dotnet; then
ver="$(dotnet --version)"
major="${ver%%.*}"
if [[ "$major" -ge 8 ]]; then
echo ".NET SDK is already installed (version $ver). No action needed."
exit 0
fi
echo ".NET SDK detected (version $ver) but < 8; proceeding to install latest .NET 8 SDK."
fi

DL_TOOL=""
if need_cmd curl; then DL_TOOL="curl -fsSL"
elif need_cmd wget; then DL_TOOL="wget -qO-"
else
echo "Error: need curl or wget"
exit 1
fi

INSTALL_DIR="${INSTALL_DIR:-$HOME/.dotnet_sdk}"
mkdir -p "$INSTALL_DIR"

INSTALL_SCRIPT_URL="https://dot.net/v1/dotnet-install.sh"
INSTALL_SCRIPT_PATH="$INSTALL_DIR/dotnet-install.sh"

echo "Downloading dotnet-install.sh to $INSTALL_SCRIPT_PATH"
$DL_TOOL "$INSTALL_SCRIPT_URL" > "$INSTALL_SCRIPT_PATH"
chmod +x "$INSTALL_SCRIPT_PATH"

echo "Installing .NET SDK to $INSTALL_DIR"
"$INSTALL_SCRIPT_PATH" --channel 8.0 --install-dir "$INSTALL_DIR" --no-path

DOTNET_BIN="$INSTALL_DIR"
EXPORT_LINE="export PATH=\"$DOTNET_BIN:\$PATH\""
MARKER="# >>> antigravity dotnet >>>"

write_profile() {
local f="$1"
[[ -f "$f" ]] || touch "$f"
if ! grep -q "$MARKER" "$f"; then
echo "Updating profile: $f"
{
echo ""
echo "$MARKER"
echo "$EXPORT_LINE"
echo "# <<< antigravity dotnet <<<"
} >> "$f"
else
echo "Profile already updated: $f"
fi
}

# Update common profiles
if [[ -n "${BASH_VERSION:-}" ]]; then
write_profile "$HOME/.bashrc"
fi
if [[ -n "${ZSH_VERSION:-}" ]]; then
write_profile "$HOME/.zshrc"
fi
write_profile "$HOME/.profile"

echo ""
echo "Installed .NET 8 SDK under $INSTALL_DIR"
echo "Restart your shell / Antigravity session, then verify:"
echo " dotnet --version"