image-gen-cli
Copilot instructions1 starsChanged 11 months agoMITView on GitHub
Multi-provider image generation CLI using .NET 10 and System.CommandLine. Provider pattern - all providers implement IImageGenerationClient with a single method: Key files: - src/Program.cs - CLI parsing, provider instantiation, validation, output handling - src/IImageGenerationClient.cs - Provider interface - src/GeminiImageClient.cs - Google Gemini API (direct HTTP, no SDK) - src/OpenAIImageClient.cs - OpenAI API (direct HTTP, no SDK) - src/Models/ - Provider-agnostic request/response types Gemini: - Uses generativelanguage.googleapis.com/v1beta API directly - imageSize parameter only works with Pro models; Flash models ignore it…
- Reads credentials
The file
We split this copilot-instructions.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Provider pattern: - all providers implement IImageGenerationClient with a single method:
- Very specific: line 40
Create NewProviderImageClient.cs implementing IImageGenerationClient
- Distinctive: line 43
Default model switch (~line 99)
- Distinctive: line 59
No system prompt, temperature, or resolution support (validated at runtime - causes error)
- Very specific: line 81
Use .tmp/ directory for test outputs (gitignored).
≈ “Common” is an estimate: at least 1 in 5 of the 3,950 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for image-gen-cli
Multi-provider image generation CLI using .NET 10 and System.CommandLine.
Quick Commands
# Build
dotnet build src/ImageGenCli.csproj
# Run directly (development)
dotnet run --project src/ImageGenCli.csproj -- "prompt"
# Install as global tool
dotnet pack src/ImageGenCli.csproj -c Release -o ./nupkg
dotnet tool install --global --add-source ./nupkg ImageGenCli
# Then use anywhere
image-gen "prompt"
image-gen -p openai "prompt" # OpenAI provider
image-gen -i image.png "edit" # With reference imageArchitecture
Provider pattern - all providers implement IImageGenerationClient with a single method:
Task<GenerationResult> GenerateImagesAsync(GenerationRequest request, CancellationToken ct)Key files:
- src/Program.cs - CLI parsing, provider instantiation, validation, output handling
- src/IImageGenerationClient.cs - Provider interface
- src/GeminiImageClient.cs - Google Gemini API (direct HTTP, no SDK)
- src/OpenAIImageClient.cs - OpenAI API (direct HTTP, no SDK)
- src/Models/ - Provider-agnostic request/response types
Adding a New Provider
- Create
NewProviderImageClient.csimplementingIImageGenerationClient - In
Program.cs, add to:- API key resolution switch (~line 84)
- Default model switch (~line 99)
- Provider validation array (~line 106)
- Provider-specific parameter validation (~line 131)
- Client instantiation switch (~line 171)
Provider-Specific Notes
Gemini:
- Uses
generativelanguage.googleapis.com/v1betaAPI directly imageSizeparameter only works with Pro models; Flash models ignore it- Supports
systemInstructionfor system prompts - Returns both images and optional text in response
OpenAI:
/v1/images/generationsfor text-only prompts/v1/images/editswith multipart form for reference images- No system prompt, temperature, or resolution support (validated at runtime - causes error)
- Maps aspect ratios to fixed pixel dimensions in
MapSize()(e.g.,16:9→1536x1024)
Conventions
- No SDK dependencies - both clients use raw
HttpClientwith direct JSON serialization - Models use
requiredandinit- immutable request types with required fields - Error handling - throw
ImageGenerationExceptionfor API errors; letHttpRequestExceptionpropagate for network issues - Provider validation - unsupported parameter combinations cause hard errors (not warnings) for agent-friendliness
- Output naming -
{provider}-{timestamp}.{ext}or{provider}-{timestamp}-{n}.{ext}for multiple
Environment Variables
GEMINI_API_KEY- Gemini providerOPENAI_API_KEY- OpenAI provider
Agent Skill
See image-gen/SKILL.md for the Agent Skills definition with complete usage documentation.
Test Outputs
Use .tmp/ directory for test outputs (gitignored).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

