Friday, October 17, 2025
HomePowershellWhen a Script is Value a Thousand AI Prompts

When a Script is Value a Thousand AI Prompts


Ever fallen in love with a shiny new software a lot that you simply begin utilizing it for all the pieces? That’s precisely what occurred to me with AI. Like a baby with a brand new toy, I used to be throwing AI at virtually each drawback I encountered—together with ones that didn’t really want it. Someplace alongside the best way, I’d forgotten my scripting roots and the elegant simplicity they provide.

When Git Will get Difficult: A Story of Department Methods

I used to be not too long ago engaged on a PowerShell mission with extremely particular Git necessities. We had strict department naming conventions tied to JIRA tickets, completely different guidelines for various file sorts, and exact formatting necessities for commit messages. Even seasoned builders on our workforce would sometimes mess up the workflow.

Quite than writing up documentation that no person would learn, I believed I’d automate the method. And since AI was my go-to resolution for all the pieces as of late, I made a decision to create an AI rule file to deal with all our Git operations.

# Git Model Management Guidelines and Necessities

This PowerShell mission makes use of a Git repository within the workspace and has particular guidelines for branching and Git commits you will need to comply with.

## Vital Common Directions that apply to all Git commits

1. Don't commit any adjustments until requested.
2. All the time ask for affirmation earlier than commiting any code.
3. Earlier than committing any adjustments to an area department, all the time first pull from the distant grasp department to get the most recent adjustments and merge them into your present working department. After guaranteeing your department is up-to-date with grasp and any conflicts are resolved, you may then commit your adjustments to your native working department.
4. All the time test for any staged adjustments and assume the consumer desires to commit these. If there are unstaged adjustments, all the time ask the consumer in the event that they'd like to incorporate these additionally.
5. Except specified by the consumer, all the time have a look at the adjustments made and provide you with a descriptive commit message.
6. When an area commit is full, all the time ask the consumer in the event that they'd prefer to push to the distant repo.

## Model Management Guidelines by File Sort

There are three distinct classes of adjustments you want to concentrate on. Every class has it is personal requiremnets you will need to adhere to.

### Pester Take a look at Code Adjustments

All information situated in `/..../PesterTests` are Pester checks. All commits for these information require th Git department to be on `....`. The `....` is the identify of the related JIRA ticket for all Pester check adjustments.

Don't permit the consumer or your self to commit adjustments to every other department when making adjustments to Pester checks apart from the `.....` department.

By no means commit a change to a C# supply code file to the `....` department.

All commmit messages that change Pester checks should comprise the JIRA challenge (...), the commit message and `...`. For instance: `[...]  ...`

### PowerShell Cmdlet Adjustments

All information situated in in any folder apart from `...` are thought of PowerShell cmdlet supply information. All adjustments to those information will need to have an related JIRA ticket quantity and department.

Any change to PowerShell cmdlet supply should be executed in a department referred to as `...`. If the consumer has not supplied a JIRA challenge for the commit and adjustments to C# supply code information are obligatory, don't commit the chnage.

All commit messages for PowerShell cmdlet supply code should comprise the particular JIRA challenge quantity, commit message and `CR:none` e.g. `...`

By no means permit a change to a PowerSHell cmdlet supply file with out an related JIRA ticket quantity.

## Pull Requests

When requested to carry out a pull request (ONLY UPON REQUEST), you will need to all the time create the pull request within the kind: `[]  CR:none` and assign the reviewer of the PR to ... and the an assignee of adbertram. You'll be able to create PRs by way of the Github CLI.

## Required Workflow for Git Adjustments.

When requested to commit adjustments:

1. Uncover the kind of information concerned in pending adjustments (Pester checks or PowerShell Cmdlet Code).
2. Test the department you are at present on.
3. If any Pester checks are pending adjustments:
    - In case you're not on the required department (`....`):
        - Stash all adjustments.
        - Change to the `...` department.
        - Pull the most recent adjustments from the distant `....` department (if it exists and has been pushed earlier than).
        - Pull the most recent adjustments from the distant fundamental department (e.g., grasp, fundamental, develop) and merge them into `....`. Resolve any merge conflicts.
        - Unstash ONLY Pester check information. If unstashing causes conflicts with the merged adjustments from fundamental, resolve them.
        - Commit adjustments following all commit message guidelines.
    - In case you are on the required department (`...`):
        - Pull the most recent adjustments from the distant `....` department (if it exists and has been pushed earlier than).
        - Pull the most recent adjustments from the distant fundamental department (e.g., grasp, fundamental, develop) and merge them into `....`. Resolve any merge conflicts.
        - Stage ONLY Pester checks and commit adjustments following all commit message guidelines.
4. If any adjustments are to PowerShell Cmdlet/C# supply code information:
    - If not already identified, ask the consumer what JIRA ticket it is best to use for these adjustments.
    - In case you're not on the required department (`....`):
        - Stash all adjustments.
        - Change to or create the required characteristic department (e.g., `....`). It is good observe to base new characteristic branches off the most recent fundamental department.
        - Pull the most recent adjustments from the distant counterpart of this characteristic department (if it exists and has been pushed earlier than).
        - Pull the most recent adjustments from the distant grasp department and merge them into the present characteristic department. Resolve any merge conflicts.
        - Unstash ONLY PowerShell Cmdlet/C# supply code information. If unstashing causes conflicts with the merged adjustments from fundamental, resolve them.
        - Commit adjustments following all commit message guidelines.
    - In case you are on the required department:
        - Pull the most recent adjustments from the distant counterpart of this characteristic department (if it exists and has been pushed earlier than).
        - Pull the most recent adjustments from the distant fundamental department (e.g., grasp, fundamental, develop) and merge them into the present characteristic department. Resolve any merge conflicts.
        - Stage ONLY PowerShell Cmdlet/C# supply code information and commit adjustments following all commit message guidelines.

Did it work? Certain, most of the time. However there have been all the time these irritating edge instances—commit messages formatted barely improper, department switching occurring within the improper order, or the AI deciding to commit adjustments regardless of my specific rule #1: “Don’t commit any adjustments until requested.

AI, it seems, might be as cussed as a decided toddler typically.

The Lightbulb Second: Again to Fundamentals

Then it hit me. Why was I utilizing AI—with all its artistic unpredictability—for a course of that must be 100% predictable? The answer was staring me within the face all alongside:

When you must commit a change by way of Git, run the script git_workflow.sh.

One easy line changed pages of AI directions. I crafted a Bash script that dealt with all the pieces my AI guidelines had been attempting to do, however with excellent consistency:

#!/bin/bash

# This script automates the Git workflow for aPowerShell mission based on model management necessities

set -e  # Exit on any error

# Colours for output
RED='33[0;31m'
GREEN='33[0;32m'
YELLOW='33[0;33m'
BLUE='33[0;34m'
NC='33[0m' # No Color

# Configuration
PESTER_TEST_PATH="PowerShell/PesterTests"
PESTER_BRANCH="...."
MAIN_BRANCH="master"  # Change to master or main if needed
WORKSPACE_ROOT="...."

# Change to workspace root
cd "$WORKSPACE_ROOT"

<--SNIP-->

  # Ask for commit message
  read -p "Enter a brief description for the source code changes: " SOURCE_MESSAGE
  COMMIT_MESSAGE="[xxxxx-$JIRA_NUMBER] $SOURCE_MESSAGE CR:none"

  # Commit adjustments
  print_message $BLUE "Committing supply code adjustments with message: $COMMIT_MESSAGE"
  git commit -m "$COMMIT_MESSAGE"
fi

# Ask if consumer desires to push adjustments
if verify "Would you prefer to push these adjustments to the distant repository?"; then
  CURRENT_BRANCH=$(git department --show-current)
  print_message $BLUE "Pushing adjustments to origin/$CURRENT_BRANCH..."
  git push -u origin "$CURRENT_BRANCH"
  print_message $GREEN "Adjustments pushed efficiently!"
else
  print_message $YELLOW "Adjustments dedicated domestically however not pushed to distant."
fi

print_message $GREEN "Git workflow accomplished efficiently!"

Wait—did I say I crafted this script? That’s not solely correct. My Bash abilities have gathered a good bit of rust over time, so I really requested AI to assist write it. The distinction? As a substitute of asking AI to carry out a fancy course of repeatedly, I requested it to create a software that reliably carry out that course of.

And that’s once I had my epiphany.

The Hammer and Nail Syndrome

I’d fallen sufferer to the basic “when all you’ve is a hammer, all the pieces seems to be like a nail” syndrome. AI had turn into my shiny new hammer, and I used to be hammering away at issues that may have been higher dealt with with a screwdriver—or on this case, a very good old school script.

In my protection, it’s simple to get swept up within the AI revolution. Pure language interfaces make all the pieces so accessible that we will neglect different approaches exist. A yr in the past, I most likely would have thought “script” instantly. Now, my first intuition is to immediate an AI.

To be honest to myself, I couldn’t have simply requested AI to generate that Git script out of the blue. I might solely create it as a result of I had already outlined all the course of in my rule file. I had executed all of the onerous work of defining the workflow; I simply couldn’t see the forest for the bushes when choosing the right implementation.

The Proper Instrument for the Proper Job

This expertise jogged my memory of a basic precept: AI may not be the optimum resolution if a course of might be clearly outlined with particular steps and predictable outcomes. Right here’s why scripts typically outshine AI for deterministic duties:

Scripts: The Dependable Workhorses

    1. Consistency and Reliability: Scripts carry out the identical approach each single time. Give them the identical enter, and also you’ll get the identical output—no surprises. Conversely, AI thrives on artistic variations that may be problematic if you want absolute consistency.
    2. Useful resource Effectivity: Working an area script makes use of minimal assets in comparison with making API calls to an AI mannequin. This distinction turns into vital with frequent operations.
    3. Debugging Made Easy: When a script misbehaves, you may pinpoint the precise line inflicting bother. With AI, troubleshooting feels extra like psychoanalysis than programming.
    4. Model Management: Scripts might be versioned, examined, and rolled again with customary instruments. AI prompts typically exist as textual content blobs that evolve haphazardly over time.

AI: The Inventive Drawback Solver

That’s to not say AI doesn’t have its place. AI really shines when:

    1. You’re deciphering pure language with all its messy nuances
    2. It’s essential to establish patterns in advanced, unstructured information
    3. Inventive options or content material era are required
    4. Necessities are ambiguous or nonetheless evolving

Scripts: The Methodical Executors

On the flip aspect, attain for a script when coping with:

    1. File operations and predictable information transformations
    2. Automated system duties that comply with clear patterns
    3. Information validation the place the foundations don’t change
    4. Repeatable enterprise processes with well-defined steps

Discovering the Candy Spot: A Hybrid Method

The simplest strategy combines the strengths of each instruments. Right here’s my new workflow:

  1. Outline Your Course of First: Totally doc your workflow earlier than reaching for any software. What are the steps? What are the foundations? What are the anticipated outcomes?
  2. Determine Resolution Factors: Decide the place real decision-making is required versus easy if/then logic. This helps decide the place AI may add worth.
  3. Contemplate Lengthy-Time period Upkeep: Contemplate who will preserve the answer and the way updates will probably be dealt with. Scripts have a transparent benefit right here.
  4. Use AI as a Co-Creator: Upon getting a well-defined course of, AI will help create the preliminary script or optimize sure elements, simply because it helped me with the Bash script.

Keep in mind: AI is a strong amplifier of human capabilities, not a substitute for considerate course of design.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments