|
| 1 | +# API Reference: How to Use the Template Tools |
| 2 | + |
| 3 | +This page explains all the scripts, workflows, and tools included in the template and how to use them. |
| 4 | + |
| 5 | +**Note**: This template doesn't include a working application - these are tools for managing documentation and automation. |
| 6 | + |
| 7 | +## Scripts You Can Run |
| 8 | + |
| 9 | +### setup.sh - Initial Setup |
| 10 | + |
| 11 | +Sets up your environment when you first start using the template. |
| 12 | + |
| 13 | +**How to Run**: |
| 14 | +```bash |
| 15 | +./scripts/setup.sh |
| 16 | +``` |
| 17 | + |
| 18 | +**What It Does**: |
| 19 | +1. Checks if you have Git and Node.js |
| 20 | +2. Verifies all folders exist |
| 21 | +3. Asks if you want to install helpful tools |
| 22 | +4. Runs quick tests |
| 23 | +5. Reports how long it took (goal: under 10 minutes) |
| 24 | + |
| 25 | +**When It Finishes Successfully**: |
| 26 | +- You'll see green checkmarks (✓) |
| 27 | +- Exit code will be 0 |
| 28 | +- You're ready to start working |
| 29 | + |
| 30 | +**If Something Goes Wrong**: |
| 31 | +- You'll see red X marks (✗) |
| 32 | +- Exit code will be 1 |
| 33 | +- Read the error message for what to fix |
| 34 | + |
| 35 | +**What Just Happened?** |
| 36 | +Exit codes are numbers programs return when they finish. 0 means success, 1 means error. Other programs can check this to know if the script worked. |
| 37 | + |
| 38 | +### validate-mermaid.sh - Check Diagrams |
| 39 | + |
| 40 | +Checks if your Mermaid diagrams have syntax errors. |
| 41 | + |
| 42 | +**How to Run**: |
| 43 | +```bash |
| 44 | +./scripts/validate-mermaid.sh |
| 45 | +``` |
| 46 | + |
| 47 | +**What You Need First**: |
| 48 | +- mermaid-cli installed: `npm install -g @mermaid-js/mermaid-cli` |
| 49 | + |
| 50 | +**What It Does**: |
| 51 | +- Finds all `.mmd` files in `docs/diagrams/` |
| 52 | +- Tests each one to see if it's valid |
| 53 | +- Reports which ones have errors |
| 54 | + |
| 55 | +**Output You'll See**: |
| 56 | +``` |
| 57 | +Found 3 diagram(s) to validate... |
| 58 | +
|
| 59 | +Checking architecture.mmd... ✓ |
| 60 | +Checking workflow.mmd... ✓ |
| 61 | +Checking pipeline.mmd... ✗ FAILED |
| 62 | + Syntax error in docs/diagrams/pipeline.mmd |
| 63 | +``` |
| 64 | + |
| 65 | +**What Just Happened?** |
| 66 | +The script tried to convert each diagram to an image. If the conversion fails, there's a syntax error in your diagram that needs fixing. |
| 67 | + |
| 68 | +### check-doc-pairs.sh - Verify Documentation Pairs |
| 69 | + |
| 70 | +Makes sure every standard documentation file has a Terry version. |
| 71 | + |
| 72 | +**How to Run**: |
| 73 | +```bash |
| 74 | +./scripts/check-doc-pairs.sh |
| 75 | +``` |
| 76 | + |
| 77 | +**What It Does**: |
| 78 | +- Looks for all `.md` files in `docs/` |
| 79 | +- For each one, checks if a `-terry.md` version exists |
| 80 | +- Reports any missing pairs |
| 81 | + |
| 82 | +**Example Output**: |
| 83 | +``` |
| 84 | +Checking documentation pairs... |
| 85 | +
|
| 86 | +Checking quickstart.md... ✓ (has Terry version) |
| 87 | +Checking tutorial.md... ✗ MISSING |
| 88 | + Expected: docs/tutorial-terry.md |
| 89 | +
|
| 90 | +✗ 1 documentation file(s) missing Terry versions |
| 91 | +``` |
| 92 | + |
| 93 | +**How to Fix Missing Pairs**: |
| 94 | +Create the missing `-terry.md` file with an accessible version of the content. |
| 95 | + |
| 96 | +**What Just Happened?** |
| 97 | +This enforces the "dual documentation" rule - every topic must exist in both standard (technical) and Terry (accessible) formats. |
| 98 | + |
| 99 | +### record-demo.sh - Record Tutorials |
| 100 | + |
| 101 | +Records your terminal session as a tutorial video. |
| 102 | + |
| 103 | +**How to Run**: |
| 104 | +```bash |
| 105 | +./scripts/record-demo.sh <tutorial-name> |
| 106 | +``` |
| 107 | + |
| 108 | +**Available Tutorials**: |
| 109 | +- `setup` - Show the complete setup process |
| 110 | +- `first-feature` - Demonstrate building a feature |
| 111 | +- `agent-workflow` - Show how the AI agent works |
| 112 | + |
| 113 | +**Example**: |
| 114 | +```bash |
| 115 | +./scripts/record-demo.sh setup |
| 116 | +# Follow the instructions on screen |
| 117 | +# Press Ctrl+D when done |
| 118 | +# Recording saved to docs/tutorials/setup.cast |
| 119 | +``` |
| 120 | + |
| 121 | +**What You Need First**: |
| 122 | +- asciinema installed (see [asciinema.org](https://asciinema.org/)) |
| 123 | + |
| 124 | +**What Just Happened?** |
| 125 | +Asciinema recorded everything you typed and displayed in your terminal. The `.cast` file can be played back to show others how to use the template. |
| 126 | + |
| 127 | +## Automated Workflows (CI/CD) |
| 128 | + |
| 129 | +These run automatically on GitHub when you push code. |
| 130 | + |
| 131 | +### validate-docs.yml - Documentation Checks |
| 132 | + |
| 133 | +**When It Runs**: |
| 134 | +- Every time you push to main |
| 135 | +- Every time you create a pull request |
| 136 | + |
| 137 | +**What It Checks**: |
| 138 | +1. Markdown files are formatted correctly (markdownlint) |
| 139 | +2. All diagrams have valid syntax (validate-mermaid.sh) |
| 140 | +3. All documentation has Terry pairs (check-doc-pairs.sh) |
| 141 | +4. All bash scripts pass quality checks (shellcheck) |
| 142 | + |
| 143 | +**If It Fails**: |
| 144 | +- Your pull request can't be merged |
| 145 | +- Check the error messages to see what to fix |
| 146 | + |
| 147 | +**What Just Happened?** |
| 148 | +GitHub automatically runs these checks to catch errors before code is merged. This is called "Continuous Integration" (CI) - automatically testing every change. |
| 149 | + |
| 150 | +### security-checks.yml - Security Scans |
| 151 | + |
| 152 | +**When It Runs**: |
| 153 | +- When you push code |
| 154 | +- When you create a pull request |
| 155 | +- Every Monday at midnight (weekly scan) |
| 156 | +- When you manually trigger it |
| 157 | + |
| 158 | +**What It Checks**: |
| 159 | +- No API keys or passwords in your code |
| 160 | +- No application code directories (template is infrastructure-only) |
| 161 | +- No Red Hat branding |
| 162 | +- No "Amber" terminology (should use "Codebase Agent") |
| 163 | +- All scripts are executable |
| 164 | + |
| 165 | +**Example Errors**: |
| 166 | +``` |
| 167 | +❌ AWS access key pattern detected! |
| 168 | +Never commit secrets. Use environment variables. |
| 169 | +``` |
| 170 | + |
| 171 | +**How to Fix**: |
| 172 | +- Remove the secret from your code |
| 173 | +- Use environment variables instead |
| 174 | +- Check `.gitignore` is blocking sensitive files |
| 175 | + |
| 176 | +**What Just Happened?** |
| 177 | +The workflow scanned your code for common security problems. Catching these early prevents accidentally sharing secrets or sensitive information. |
| 178 | + |
| 179 | +### rebuild-demos.yml - Tutorial Auto-Update |
| 180 | + |
| 181 | +**When It Runs**: |
| 182 | +- When you change files in `docs/`, `scripts/`, or `.claude/` |
| 183 | +- When you manually trigger it |
| 184 | + |
| 185 | +**What It Does**: |
| 186 | +1. Installs asciinema |
| 187 | +2. Re-records all tutorials automatically |
| 188 | +3. Saves the updated recordings |
| 189 | +4. Commits them to your repository |
| 190 | + |
| 191 | +**Why This Exists**: |
| 192 | +Keeps tutorial videos in sync with code changes. When you update the setup script, the setup tutorial automatically updates too. |
| 193 | + |
| 194 | +**What Just Happened?** |
| 195 | +GitHub Actions (GitHub's automation service) ran the script on their servers and saved the results back to your repository. |
| 196 | + |
| 197 | +## AI Agent Configuration |
| 198 | + |
| 199 | +### .claude/agents/codebase-agent.md |
| 200 | + |
| 201 | +Defines the AI agent's personality and what it can do. |
| 202 | + |
| 203 | +**What's In It**: |
| 204 | +- Agent's name and role |
| 205 | +- What tasks it can help with (issue-to-PR, code reviews) |
| 206 | +- How it should behave (careful, high-quality) |
| 207 | +- How much autonomy it has (when to ask permission) |
| 208 | + |
| 209 | +**How It's Used**: |
| 210 | +When you work in this repository with Claude Code, it reads this file to understand how to help you. |
| 211 | + |
| 212 | +### .claude/context/*.md Files |
| 213 | + |
| 214 | +These are "knowledge modules" that teach the agent about your project. |
| 215 | + |
| 216 | +**Available Modules**: |
| 217 | +- `architecture.md` - How the template is organized |
| 218 | +- `security-standards.md` - How to write secure code |
| 219 | +- `testing-patterns.md` - How to write tests |
| 220 | + |
| 221 | +**Special Feature - Independence**: |
| 222 | +Each module works on its own - you can copy just one to a different project and it still makes sense. |
| 223 | + |
| 224 | +**What Just Happened?** |
| 225 | +Instead of one huge file explaining everything, we split knowledge into separate modules. This makes it easier to maintain and lets you pick just what you need (buffet approach). |
| 226 | + |
| 227 | +### .claude/commands/*.md Files |
| 228 | + |
| 229 | +Custom commands you can use with the AI agent. |
| 230 | + |
| 231 | +**Example - quickstart.md**: |
| 232 | +When you type `/quickstart`, the agent responds with setup instructions. |
| 233 | + |
| 234 | +**What's In A Command File**: |
| 235 | +```markdown |
| 236 | +# /quickstart command |
| 237 | + |
| 238 | +Provide rapid setup instructions for new developers. |
| 239 | + |
| 240 | +## Response Template |
| 241 | + |
| 242 | +1. Clone repository |
| 243 | +2. Run ./scripts/setup.sh |
| 244 | +3. Verify installation |
| 245 | +4. Next steps |
| 246 | +``` |
| 247 | + |
| 248 | +**What Just Happened?** |
| 249 | +Commands are shortcuts that trigger specific responses from the agent. Instead of asking "how do I set up?" you just type `/quickstart`. |
| 250 | + |
| 251 | +## The Comparison Page |
| 252 | + |
| 253 | +### docs/comparison/index.html |
| 254 | + |
| 255 | +A webpage that shows standard and Terry documentation side-by-side. |
| 256 | + |
| 257 | +**How to Open It**: |
| 258 | +```bash |
| 259 | +# macOS: |
| 260 | +open docs/comparison/index.html |
| 261 | + |
| 262 | +# Linux: |
| 263 | +xdg-open docs/comparison/index.html |
| 264 | + |
| 265 | +# Windows: |
| 266 | +start docs/comparison/index.html |
| 267 | +``` |
| 268 | + |
| 269 | +**What It Uses**: |
| 270 | +- marked.js - Converts markdown to HTML |
| 271 | +- highlight.js - Colors code examples |
| 272 | + |
| 273 | +**How It Works**: |
| 274 | +1. Click a topic tab (like "Quickstart") |
| 275 | +2. JavaScript loads `quickstart.md` and `quickstart-terry.md` |
| 276 | +3. Markdown is converted to HTML |
| 277 | +4. Both versions display side-by-side |
| 278 | + |
| 279 | +**What Just Happened?** |
| 280 | +The page loads markdown files from your computer and renders them in your browser. Everything happens client-side (in your browser) - no server needed. |
| 281 | + |
| 282 | +## File Naming Patterns |
| 283 | + |
| 284 | +### Documentation Files |
| 285 | + |
| 286 | +**Standard Version**: `docs/{topic}.md` |
| 287 | +- Example: `docs/quickstart.md` |
| 288 | +- Written for developers |
| 289 | + |
| 290 | +**Terry Version**: `docs/{topic}-terry.md` |
| 291 | +- Example: `docs/quickstart-terry.md` |
| 292 | +- Written for everyone |
| 293 | + |
| 294 | +**How to Check**: `./scripts/check-doc-pairs.sh` |
| 295 | + |
| 296 | +### Diagram Files |
| 297 | + |
| 298 | +**Location**: `docs/diagrams/{name}.mmd` |
| 299 | +- Example: `docs/diagrams/architecture.mmd` |
| 300 | + |
| 301 | +**How to Validate**: `./scripts/validate-mermaid.sh` |
| 302 | + |
| 303 | +**How to Create**: |
| 304 | +```mermaid |
| 305 | +graph LR |
| 306 | + A[Start] --> B[Process] |
| 307 | + B --> C[End] |
| 308 | +``` |
| 309 | + |
| 310 | +### Tutorial Files |
| 311 | + |
| 312 | +**Location**: `docs/tutorials/{name}.cast` |
| 313 | +- Example: `docs/tutorials/setup.cast` |
| 314 | + |
| 315 | +**How to Record**: `./scripts/record-demo.sh setup` |
| 316 | + |
| 317 | +**How to Play**: `asciinema play docs/tutorials/setup.cast` |
| 318 | + |
| 319 | +## Configuration Files |
| 320 | + |
| 321 | +### .markdownlint.json |
| 322 | + |
| 323 | +Controls how strict markdown checking is. |
| 324 | + |
| 325 | +**What It Says**: |
| 326 | +```json |
| 327 | +{ |
| 328 | + "MD013": false, // Don't complain about long lines |
| 329 | + "MD033": { |
| 330 | + "allowed_elements": ["details", "summary", "br"] // Allow some HTML |
| 331 | + }, |
| 332 | + "MD041": false // Don't require h1 as first line |
| 333 | +} |
| 334 | +``` |
| 335 | + |
| 336 | +**What Just Happened?** |
| 337 | +Markdown linting has many rules. This file turns off rules that are too strict for our documentation style. |
| 338 | + |
| 339 | +### .github/dependabot.yml |
| 340 | + |
| 341 | +Tells GitHub to automatically update dependencies. |
| 342 | + |
| 343 | +**What It Does**: |
| 344 | +- Checks for updates every Monday |
| 345 | +- Creates pull requests for new versions |
| 346 | +- Groups related updates together |
| 347 | + |
| 348 | +**Why This Matters**: |
| 349 | +Keeps your tools up to date automatically without you having to check manually. |
| 350 | + |
| 351 | +## Understanding Exit Codes |
| 352 | + |
| 353 | +When scripts finish, they return a number: |
| 354 | + |
| 355 | +**0 = Success** - Everything worked! |
| 356 | +**1 = Error** - Something went wrong |
| 357 | + |
| 358 | +**Why This Matters**: |
| 359 | +Other programs (like CI/CD) check exit codes to know if a script succeeded. If setup.sh returns 1, the workflow knows setup failed. |
| 360 | + |
| 361 | +**Example**: |
| 362 | +```bash |
| 363 | +./scripts/validate-mermaid.sh |
| 364 | +echo $? # Prints the exit code (0 or 1) |
| 365 | +``` |
| 366 | + |
| 367 | +## Troubleshooting |
| 368 | + |
| 369 | +**"Command not found" errors**: |
| 370 | +- Script isn't executable: `chmod +x scripts/*.sh` |
| 371 | +- Tool not installed: Check the "What You Need First" section |
| 372 | + |
| 373 | +**"No such file or directory"**: |
| 374 | +- Wrong folder: Run `pwd` to see where you are |
| 375 | +- File doesn't exist yet: Check if you created it |
| 376 | +- Typo in filename: Check spelling exactly |
| 377 | + |
| 378 | +**"Permission denied"**: |
| 379 | +- Script needs execute permission: `chmod +x scripts/{script}.sh` |
| 380 | +- Git credentials issue: Run `gh auth login` |
| 381 | + |
| 382 | +## Learn More |
| 383 | + |
| 384 | +- [Bash Scripting Guide](https://www.gnu.org/software/bash/manual/) - Learn shell scripting |
| 385 | +- [GitHub Actions Docs](https://docs.github.com/en/actions) - Learn CI/CD |
| 386 | +- [Asciinema Docs](https://asciinema.org/) - Learn terminal recording |
| 387 | +- [Mermaid Docs](https://mermaid.js.org/) - Learn diagram syntax |
| 388 | + |
| 389 | +--- |
| 390 | + |
| 391 | +**Next**: Check out the [Development](development-terry.md) guide to learn the daily workflow for working with this template. |
0 commit comments