create-guid: Simple CLI Tool for Generating GUIDs

In modern software development, GUIDs (Globally Unique Identifiers) are used everywhere: from identifying database records and correlation tokens to generating unique keys for distributed systems. While System.Guid.NewGuid() is the standard way to generate GUIDs in .NET, there are scenarios where you want a tool that gives you quick and scriptable access to GUIDs from the command line or inside CI/CD pipelines.

Let’s take a look at a small but mighty utility: create-guid, a cross-platform .NET CLI tool for generating GUIDs with ease.

Why Use create-guid?

Whether you’re bootstrapping new projects, scripting resource creation, or injecting unique values in CI/CD workflows, this tool gives you:

  • Simple command-line usage
  • Support for UUIDv7 (time-ordered GUIDs)
  • Options for generating multiple GUIDs at once
  • Ability to return empty GUIDs for testing or placeholder needs
  • Easy installation via dotnet tool

Getting Started

Installation

You can install create-guid globally using the .NET CLI:

dotnet tool install --global D20Tek.Tools.CreateGuid

To update the tool when a new version is released:

dotnet tool update --global D20Tek.Tools.CreateGuid

Usage

Once installed, you can use the createguid command from any terminal or script:

create-guid [options]

Options

OptionDescription
--count <n>Number of GUIDs to generate (default: 1)
--uuidv7Generate UUIDv7 instead of standard GUIDs
--emptyOutput empty GUIDs
-h, --helpShow help information

Examples

Generate a single standard GUID:

create-guid

Generate 5 UUIDv7s:

create-guid --count 5 --uuidv7

Generate 3 GUIDs and copy them to the clipboard:

create-guid -c 3 --clipboard-copy

Here is the full help text for your reference for the create-guid tool:

USAGE:
    create-guid [OPTIONS] [COMMAND]

OPTIONS:
                                         DEFAULT
    -h, --help                                      Prints help information
    -v, --verbosity <VERBOSITY-LEVEL>    Normal     The verbosity level for this operation: q(uiet), m(inimal),
                                                    n(ormal), d(etailed), and diag(nostic)
    -c, --count <COUNT>                  1          The number of GUIDs to generate (defaults to 1)
    -f, --format <GUID-FORMAT>           Default    Defines how the GUIDs are formatted in string form (Default, Number,
                                                    Braces, Parens, Hex)
    -s, --uuid-v7                                   Generates a UUID v7 compliant GUID for sortable unique identifiers
    -e, --empty                                     Defines if the GUIDs should be empty (using zero-values)
    -u, --upper                                     Defines if the generated GUIDs should be upper-cased (defaults to
                                                    lower-cased)
    -p, --clipboard-copy                            Defines whether the output of this command should be copied to the
                                                    system clipboard
    -o, --output                                    Filename for output file used to save generated guids

COMMANDS:
    generate    Default command that generates GUIDs in the appropriate format

What is UUIDv7?

UUIDv7 is a new format designed for time-ordered GUIDs. It combines a timestamp and random bits, offering:

  • Natural ordering by generation time
  • Improved performance in databases with indexing
  • Better support for distributed systems with temporal precision

The --uuidv7 flag enables this mode if you’re targeting use cases that benefit from chronological sorting.


Using in CI/CD Pipelines

The create-guid tool is perfect for CI/CD pipelines in GitHub Actions, Azure DevOps, or any shell-based automation, where you need a GUID. Here’s how to integrate it:

GitHub Actions Example

name: Generate GUID Example

on: [push]

jobs:
  guid-job:
    runs-on: ubuntu-latest
    steps:
      - name: Install .NET SDK
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x'

      - name: Install create-guid CLI tool
        run: dotnet tool install --global D20Tek.Tools.CreateGuid

      - name: Generate a UUIDv7
        run: |
          NEW_GUID=$(createguid --uuidv7 --verbosity minimal)
          echo "Generated UUIDv7: $NEW_GUID"

      - name: Use GUID in a script
        run: |
          echo "##[set-output name=guid;]$NEW_GUID"

This approach gives you a GUID at runtime that you can use for versioning, labeling, unique keys, or tagging artifacts.


Final Thoughts

Sometimes the most useful tools are the simplest. create-guid offers an elegant solution for a common need – creating unique identifiers quickly and reliably, with both the old-school UUIDv4 and modern UUIDv7 support.

If you’re scripting in the terminal, building templates, or wiring up automation in CI/CD, give it a try and let us know what you think!

Leave a comment