<?xml version="1.0" encoding="UTF-8"?>
<gsl-prompt id="20250731T194500-0400" type="feat">
<gsl-header>

# Add Prompt Validation, Harmonization, and Trace ID to OBK CLI
</gsl-header>
<gsl-block>
<gsl-purpose>
<gsl-title>

## 1. Purpose
</gsl-title>
<gsl-description>

Implement prompt file validation, harmonization, and trace ID generation as OBK CLI features, closely following the guide on best practices. All commands must fit OBK’s CLI structure and use the provided XSD schema for validation. 
</gsl-description>
</gsl-purpose>
<gsl-inputs>
<gsl-title>

## 2. Inputs
</gsl-title>
<gsl-description>

| Input                                    | Notes                                                                                       |
| ---------------------------------------- | ------------------------------------------------------------------------------------------- |
| `prompt-validation-harmonization-guide.md` | Article outlining the design and reference code for validation, harmonization, and trace ID |
| `one-line-manual-tests.md`                | Article on the manual-test-first workflow and TDD best practices                            |
| `gsl-prompt.xsd`                          | OBK’s XML schema for validating prompt files                                                |                      |
| `get\_prompt\_id.py                       | Reference script for the trace ID command (most up-to-date logic`)                           |
| Stubbed prompt `20250731T194500-0400.md`   |                           |
| `do-harmonize-validate-prompt-id.md` Codex Task   |                           |


</gsl-description>
</gsl-inputs>

<gsl-outputs>
<gsl-title>

## 3. Outputs
</gsl-title>
<gsl-description>

- Completed prompt `20250731T194500-0400.md`
- Added source code and automated tests 
</gsl-description>
</gsl-outputs>
<gsl-workflows>
<gsl-title>

## 4. Workflows
</gsl-title>
<gsl-description>

#### Trace ID

1. `obk trace-id`
2. `obk trace-id -h`

#### Validate All

1. `obk validate-all`
2. `obk validate-all -h`

#### Validate Today

1. `obk validate-today`
2. `obk validate-today -h`

#### Harmonize All

1. `obk harmonize-all`
2. `obk harmonize-all -h`

#### Harmonize Today

1. `obk harmonize-today`
2. `obk harmonize-all -h`

</gsl-description>
</gsl-workflows>
<gsl-acceptance-tests>
<gsl-title>

## 5. Acceptance Tests
</gsl-title>

<gsl-acceptance-test id="1">
<gsl-performed-action>

1. When I run `obk validate-all` from any directory with both valid and invalid prompt files present
</gsl-performed-action>
<gsl-expected-result>

    The CLI validates all prompt files against the schema, prints errors for invalid files, "All prompt files are valid." if all pass, and exits with 0 if all pass, 1 if any file fails, and 2 if the prompts directory is missing.
</gsl-expected-result>
</gsl-acceptance-test>

<gsl-acceptance-test id="2">
<gsl-performed-action>

2. When I run `obk harmonize-all --dry-run` from any subdirectory
</gsl-performed-action>
<gsl-expected-result>
    
    The CLI prints all planned harmonization actions prefixed by "Would", prints a summary, and does not modify any files.
</gsl-expected-result>
</gsl-acceptance-test>

<gsl-acceptance-test id="3">
<gsl-performed-action>

3. When I run `obk trace-id --timezone America/New_York` and with an invalid timezone
</gsl-performed-action>
<gsl-expected-result>

    The CLI prints a trace ID in the correct format for a valid timezone and a clear error for an invalid timezone.
</gsl-expected-result>
</gsl-acceptance-test>

<gsl-acceptance-test id="4">
<gsl-performed-action>

4. When I run `obk validate-today` or `obk harmonize-today` on a day with no prompt files for today
</gsl-performed-action>
<gsl-expected-result>
    
    The CLI prints "No prompt files found." and a summary with 0 files processed, and exits with code 0.
</gsl-expected-result>
</gsl-acceptance-test>

<gsl-acceptance-test id="5">
<gsl-performed-action>

5. When I run `obk validate-today` or `obk harmonize-today` with some valid and some invalid files for today
</gsl-performed-action>
<gsl-expected-result>

    The CLI reports the number of files passed/failed/changed, prints validation errors for invalid files, and exits with the correct status code (0 if all pass, 1 if any fail).
</gsl-expected-result>
</gsl-acceptance-test>
</gsl-acceptance-tests>
</gsl-block>
</gsl-prompt>
