|
| 1 | +--- |
| 2 | +name: implement-spec |
| 3 | +description: Implements a new Java faker feature end-to-end from a spec file. Creates a GitHub issue, a kebab-case feature branch, writes all Java and YAML files, commits, and opens a PR via create-pr.sh. Invoke manually with the path to a spec file. |
| 4 | +argument-hint: <path/to/SPEC.md> |
| 5 | +disable-model-invocation: true |
| 6 | +allowed-tools: Bash, Read, Write, Edit, Glob, Grep |
| 7 | +--- |
| 8 | + |
| 9 | +Implement the Java faker feature described in the spec file below. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Spec file: $ARGUMENTS |
| 14 | + |
| 15 | +``` |
| 16 | +!`cat "$ARGUMENTS"` |
| 17 | +``` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Instructions |
| 22 | + |
| 23 | +Follow every step in order. Do not skip any step. |
| 24 | + |
| 25 | +### Step 1 — Understand the spec |
| 26 | + |
| 27 | +Read the spec above carefully. Identify: |
| 28 | +- The feature name (e.g., "CreditCard", "Subscription") |
| 29 | +- All files to create or modify (YAML, Java class, Faker.java, test class) |
| 30 | +- The complete list of public methods and their expected behavior |
| 31 | +- The verification checklist at the bottom of the spec |
| 32 | + |
| 33 | +### Step 2 — Create a GitHub issue |
| 34 | + |
| 35 | +Create an issue in the `TheJavaGuy/java-faker` repository. Derive the title from the spec's **Overview** section (one concise sentence). Use the full spec content as the body. |
| 36 | + |
| 37 | +```bash |
| 38 | +gh issue create \ |
| 39 | + --repo TheJavaGuy/java-faker \ |
| 40 | + --title "<feature title from spec Overview>" \ |
| 41 | + --body "$(cat '$ARGUMENTS')" |
| 42 | +``` |
| 43 | + |
| 44 | +Record the issue number printed (e.g., `#42`). You will reference it in the commit message. |
| 45 | + |
| 46 | +### Step 3 — Create a feature branch |
| 47 | + |
| 48 | +Derive a descriptive kebab-case branch name from the feature name. Pattern: |
| 49 | + |
| 50 | +``` |
| 51 | +add-<feature-name>-faker |
| 52 | +``` |
| 53 | + |
| 54 | +Examples: `add-credit-card-faker`, `add-markdown-faker`, `add-shipping-faker`. |
| 55 | + |
| 56 | +```bash |
| 57 | +git checkout master |
| 58 | +git pull |
| 59 | +git checkout -b add-<feature-name>-faker |
| 60 | +``` |
| 61 | + |
| 62 | +### Step 4 — Implement the spec |
| 63 | + |
| 64 | +Create or modify every file listed in the spec's **File Locations** table. Implement exactly what the spec describes — no more, no less. |
| 65 | + |
| 66 | +**Typical files for a new faker:** |
| 67 | + |
| 68 | +1. **YAML data file** — `src/main/resources/en/<feature>.yml` |
| 69 | + - Match the structure shown in the spec |
| 70 | + - Follow the YAML conventions of existing files (e.g., `vehicle.yml`, `finance.yml`) |
| 71 | + |
| 72 | +2. **Java class** — `src/main/java/org/thejavaguy/javafaker/<FeatureName>.java` |
| 73 | + - Use `package org.thejavaguy.javafaker;` |
| 74 | + - Follow the pattern of existing fakers: constructor takes `Faker faker`, methods delegate to `faker.fakeValuesService()` or other fakers |
| 75 | + - Implement all methods listed in the spec |
| 76 | + |
| 77 | +3. **Faker.java registration** — `src/main/java/org/thejavaguy/javafaker/Faker.java` |
| 78 | + - Add a `private final <FeatureName> <fieldName>;` field near similar fields |
| 79 | + - Initialize it in the constructor: `this.<fieldName> = new <FeatureName>(this);` |
| 80 | + - Add a getter method: `public <FeatureName> <fieldName>() { return <fieldName>; }` |
| 81 | + |
| 82 | +4. **Test class** — `src/test/java/org/thejavaguy/javafaker/<FeatureName>Test.java` |
| 83 | + - Extend `AbstractFakerTest` |
| 84 | + - Implement all test cases from the spec |
| 85 | + - Use AssertJ assertions (`assertThat(...)`) |
| 86 | + |
| 87 | +Before moving on, run tests and fix any failures: |
| 88 | + |
| 89 | +```bash |
| 90 | +./mvnw test -Dtest=<FeatureName>Test |
| 91 | +``` |
| 92 | + |
| 93 | +If all tests pass, also run the full suite to check for regressions: |
| 94 | + |
| 95 | +```bash |
| 96 | +./mvnw test |
| 97 | +``` |
| 98 | + |
| 99 | +### Step 5 — Commit |
| 100 | + |
| 101 | +Stage only the files you created or modified. Commit with a message that references the issue number: |
| 102 | + |
| 103 | +```bash |
| 104 | +git add src/ |
| 105 | +git commit -m "add <FeatureName> faker (closes #<issue-number>)" |
| 106 | +``` |
| 107 | + |
| 108 | +### Step 6 — Push and open PR |
| 109 | + |
| 110 | +Push the branch and create the PR using the existing helper script: |
| 111 | + |
| 112 | +```bash |
| 113 | +git push -u origin HEAD |
| 114 | +./create-pr.sh |
| 115 | +``` |
| 116 | + |
| 117 | +`create-pr.sh` automatically derives the PR title from the branch name and builds the body from the commit log. The PR will target `master`. |
| 118 | + |
| 119 | +### Done |
| 120 | + |
| 121 | +Report back with: |
| 122 | +- The GitHub issue URL |
| 123 | +- The branch name |
| 124 | +- The PR URL |
| 125 | +- A summary of all files created/modified |
0 commit comments