Skip to content

V0.7.5/trunk first repo - #30

Merged
gimlichael merged 1 commit into
mainfrom
v0.7.5/trunk-first-repo
Jul 15, 2026
Merged

V0.7.5/trunk first repo#30
gimlichael merged 1 commit into
mainfrom
v0.7.5/trunk-first-repo

Conversation

@gimlichael

Copy link
Copy Markdown
Member

This pull request updates the trunk-first-repo skill to support a safer and more robust workflow for pushing to a new remote after initializing a trunk-based repository. The main improvements clarify and automate the process of pushing the main branch before feature branches, both during and after initialization, and provide explicit instructions and safeguards to prevent common mistakes (such as accidentally making a feature branch the default branch or pushing unwanted files to main). The documentation, skill description, and evaluation tests are updated to reflect these enhancements.

Skill and Workflow Enhancements:

  • skills/trunk-first-repo/SKILL.md: Adds a "Push Remote Workflow" for safely pushing main and feature branches to a new remote even after initialization, including checks to avoid pushing from main, verifying the empty state of main, and explaining the correct push order. The workflow now explicitly recommends using git push -u origin main:main from the feature branch and clarifies that untracked/ignored files are not part of main unless committed. [1] [2] [3]

  • skills/trunk-first-repo/SKILL.md: Updates the skill description to mention support for a later "push remote" mode and the safe push order.

  • skills/trunk-first-repo/SKILL.md: Updates the day-to-day workflow to include the new push order and steps.

Documentation Updates:

  • README.md: Updates the trunk-first-repo entry to describe the new "push remote" capability, clarifies push order, and highlights the safer first push process. [1] [2]

Test and Evaluation Improvements:

  • skills/trunk-first-repo/evals/evals.json: Updates and adds evaluation cases to test the new push remote workflow, including checks for pushing main by ref, not switching branches unnecessarily, and verifying the empty state of main. [1] [2]

Split initialization into Initialize and Push Remote workflows so users can provision the trunk-first git structure before the remote URL is available. Add Step 0 to detect mode, Push Remote Workflow (Steps P1-P3) with branch and remote validation, and updated summary with push-remote guidance. Extends evals with test cases for post-initialization remote push scenarios.
@gimlichael gimlichael self-assigned this Jul 15, 2026
@gimlichael
gimlichael merged commit e347a11 into main Jul 15, 2026
1 check passed
@gimlichael
gimlichael deleted the v0.7.5/trunk-first-repo branch July 15, 2026 20:36
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a push remote mode to the trunk-first-repo skill so users who skipped the remote URL at initialization can safely push main before their feature branch, preventing hosts like GitHub from treating the feature branch as the default. It also introduces an explicit main:main ref in all push commands and adds git ls-tree -r --name-only main as the authoritative way to verify branch emptiness.

  • New Push Remote Workflow (Steps P1\u2013P3): validates current branch, confirms main is still the empty seed, resolves or adds origin, then pushes main:main followed by HEAD \u2014 all without switching branches.
  • Step 3a added to Initialize Workflow: documents the correct first-feature-push order for agents helping a user commit and publish for the first time.
  • Eval cases 4 and 5 added: cover the late-remote scenario and the explicit push remote <url> invocation, with expectations that mirror the new safety checks.

Confidence Score: 4/5

Safe to merge with a small fix to the Step 4 summary template, which always shows 'remote: not configured' even when a remote was configured in Step 3.

The dedicated Push Remote Workflow with its branch and tree validation is well-designed and the eval coverage is solid. The concrete defect is in the Step 4 summary template: it always directs the user to invoke 'push remote' even when the remote was already added and main was already pushed in Step 3, giving incorrect next steps for the common init-with-remote path.

skills/trunk-first-repo/SKILL.md — the Step 4 summary template (lines 96–113) and the relationship between Step 3a and the Push Remote Workflow.

Important Files Changed

Filename Overview
skills/trunk-first-repo/SKILL.md Adds Push Remote Workflow and Step 3a; the summary template hardcodes 'not configured' even when a remote was configured in Step 3, and Step 3a's late-remote branch duplicates the Push Remote Workflow scenario without the safety checks introduced by this PR.
skills/trunk-first-repo/evals/evals.json Adds eval cases 4 and 5 covering the late-remote push scenario and the explicit 'push remote' command; expectations are well-scoped and cover the key behaviours the new workflow introduces.
README.md Updates the trunk-first-repo skill description and adds a 'Safer first push' bullet in the Why section; changes are accurate and consistent with the skill updates.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([User invokes trunk-first-repo]) --> B{Says 'push remote'?}
    B -- Yes --> PW[Push Remote Workflow]
    B -- No --> IW[Initialize Workflow]
    IW --> S1[Step 1: Collect Parameters]
    S1 --> S2[Step 2: git init + orphan main + seed commit + feature branch]
    S2 --> S3{Remote URL provided?}
    S3 -- Yes --> S3A[Step 3: git remote add origin
git push -u origin main:main]
    S3 -- No --> S4[Step 4: Show summary]
    S3A --> S4
    S4 --> FC[User commits first files on feature branch]
    FC --> S3a[Step 3a: git push -u origin main:main
git push -u origin HEAD]
    PW --> P1[Step P1: Check current branch
Block if on main
Verify main is empty]
    P1 --> P2{origin exists?}
    P2 -- Yes --> P3
    P2 -- No, URL given --> AddOrigin[git remote add origin URL]
    P2 -- No, no URL --> AskURL[Ask for URL]
    AddOrigin --> P3
    AskURL --> P3
    P3[Step P3: git push -u origin main:main
git push -u origin HEAD] --> Done([Tell user to open PR])
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A([User invokes trunk-first-repo]) --> B{Says 'push remote'?}
    B -- Yes --> PW[Push Remote Workflow]
    B -- No --> IW[Initialize Workflow]
    IW --> S1[Step 1: Collect Parameters]
    S1 --> S2[Step 2: git init + orphan main + seed commit + feature branch]
    S2 --> S3{Remote URL provided?}
    S3 -- Yes --> S3A[Step 3: git remote add origin
git push -u origin main:main]
    S3 -- No --> S4[Step 4: Show summary]
    S3A --> S4
    S4 --> FC[User commits first files on feature branch]
    FC --> S3a[Step 3a: git push -u origin main:main
git push -u origin HEAD]
    PW --> P1[Step P1: Check current branch
Block if on main
Verify main is empty]
    P1 --> P2{origin exists?}
    P2 -- Yes --> P3
    P2 -- No, URL given --> AddOrigin[git remote add origin URL]
    P2 -- No, no URL --> AskURL[Ask for URL]
    AddOrigin --> P3
    AskURL --> P3
    P3[Step P3: git push -u origin main:main
git push -u origin HEAD] --> Done([Tell user to open PR])
Loading
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
skills/trunk-first-repo/SKILL.md:96-113
**Summary template hardcodes "not configured" regardless of Step 3 outcome**

Step 4 always renders `remote: not configured (add later with \`git remote add origin <url>\`)` and instructs the agent to direct the user to invoke `push remote <url>` — but Step 3 may have already added the remote and pushed `main:main`. An agent following this template literally will display misleading post-init information whenever the user provided a URL, and the "Next steps" list prompts unnecessary `push remote` invocation for a remote that is already configured.

The template should branch on whether a remote was configured: when one was provided, confirm the remote URL and replace steps 2–4 with only `git push -u origin HEAD` once feature-branch work is ready.

### Issue 2 of 3
skills/trunk-first-repo/SKILL.md:67-94
**Step 3a covers the same scenario as Push Remote Workflow without its safety checks**

Step 3a's second branch — "If the remote was added only after the first feature commit" — is functionally identical to the Push Remote Workflow but omits `git branch --show-current` and `git ls-tree -r --name-only main` guards that Step P1 mandates. An agent following Step 3a for this late-remote scenario would skip those guards entirely.

Consider cross-referencing the Push Remote Workflow for this case, or mirroring the Step P1 checks inline.

### Issue 3 of 3
skills/trunk-first-repo/SKILL.md:67-84
**Step 3a redundantly re-pushes `main:main` when the remote was already set up in Step 3**

When the user provided a remote URL during init, Step 3 already ran `git push -u origin main:main`. Step 3a unconditionally repeats that push before pushing `HEAD`. The second push is a silent no-op but may confuse users who see a push command appear to run without effect. A guard or an explicit note that the first command is a no-op when already pushed in Step 3 would clarify intent.

Reviews (1): Last reviewed commit: "♻️ add push-remote workflow to trunk-fir..." | Re-trigger Greptile

Comment on lines 96 to +113
@@ -65,11 +104,68 @@ After initialization, display a summary:
feature branch: v0.1.0/init (current — start working here)
remote: not configured (add later with `git remote add origin <url>`)

Next steps:
1. Stage and commit your files on this branch
2. Push the feature branch and open a PR to main
3. After review, merge the PR — main stays clean
```
Next steps:
1. Stage and commit your files on this branch
2. When the remote is ready, invoke `push remote <url>` from this branch
3. Push main first with `git push -u origin main:main`
4. Push the feature branch with `git push -u origin HEAD` and open a PR to main
5. After review, merge the PR — main stays clean
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Summary template hardcodes "not configured" regardless of Step 3 outcome

Step 4 always renders remote: not configured (add later with \git remote add origin `)and instructs the agent to direct the user to invokepush remote — but Step 3 may have already added the remote and pushedmain:main. An agent following this template literally will display misleading post-init information whenever the user provided a URL, and the "Next steps" list prompts unnecessary push remote` invocation for a remote that is already configured.

The template should branch on whether a remote was configured: when one was provided, confirm the remote URL and replace steps 2–4 with only git push -u origin HEAD once feature-branch work is ready.

Prompt To Fix With AI
This is a comment left during a code review.
Path: skills/trunk-first-repo/SKILL.md
Line: 96-113

Comment:
**Summary template hardcodes "not configured" regardless of Step 3 outcome**

Step 4 always renders `remote: not configured (add later with \`git remote add origin <url>\`)` and instructs the agent to direct the user to invoke `push remote <url>` — but Step 3 may have already added the remote and pushed `main:main`. An agent following this template literally will display misleading post-init information whenever the user provided a URL, and the "Next steps" list prompts unnecessary `push remote` invocation for a remote that is already configured.

The template should branch on whether a remote was configured: when one was provided, confirm the remote URL and replace steps 2–4 with only `git push -u origin HEAD` once feature-branch work is ready.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +67 to +94
### Step 3a: First Feature Push

After the user commits the first project files on the feature branch, push in this order:

```bash
git push -u origin main:main
git push -u origin HEAD
```

This order matters. `main` must exist on the remote before the feature branch is pushed so hosts such as GitHub do not make the feature branch the default branch for a brand-new remote.

If the remote was added only after the first feature commit, still run the same order from the feature branch:

```bash
git remote add origin {REMOTE_URL}
git push -u origin main:main
git push -u origin HEAD
```

Do not manually delete project files from the working tree to "clean" `main`. When the user is worried about files appearing on `main`, explicitly explain that untracked or ignored checkout files can remain visible in the directory but are not part of the `main` branch. If the user needs to verify that `main` is empty, inspect the branch tree instead of the checkout directory:

```bash
git ls-tree -r --name-only main
```

An empty output means `main` contains only the seed commit. Untracked or ignored files in the checkout directory are not part of `main`.

If the feature branch was accidentally pushed before `main`, push `main` next and change the remote repository's default branch to `main` before opening the PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Step 3a covers the same scenario as Push Remote Workflow without its safety checks

Step 3a's second branch — "If the remote was added only after the first feature commit" — is functionally identical to the Push Remote Workflow but omits git branch --show-current and git ls-tree -r --name-only main guards that Step P1 mandates. An agent following Step 3a for this late-remote scenario would skip those guards entirely.

Consider cross-referencing the Push Remote Workflow for this case, or mirroring the Step P1 checks inline.

Prompt To Fix With AI
This is a comment left during a code review.
Path: skills/trunk-first-repo/SKILL.md
Line: 67-94

Comment:
**Step 3a covers the same scenario as Push Remote Workflow without its safety checks**

Step 3a's second branch — "If the remote was added only after the first feature commit" — is functionally identical to the Push Remote Workflow but omits `git branch --show-current` and `git ls-tree -r --name-only main` guards that Step P1 mandates. An agent following Step 3a for this late-remote scenario would skip those guards entirely.

Consider cross-referencing the Push Remote Workflow for this case, or mirroring the Step P1 checks inline.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +67 to +84
### Step 3a: First Feature Push

After the user commits the first project files on the feature branch, push in this order:

```bash
git push -u origin main:main
git push -u origin HEAD
```

This order matters. `main` must exist on the remote before the feature branch is pushed so hosts such as GitHub do not make the feature branch the default branch for a brand-new remote.

If the remote was added only after the first feature commit, still run the same order from the feature branch:

```bash
git remote add origin {REMOTE_URL}
git push -u origin main:main
git push -u origin HEAD
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Step 3a redundantly re-pushes main:main when the remote was already set up in Step 3

When the user provided a remote URL during init, Step 3 already ran git push -u origin main:main. Step 3a unconditionally repeats that push before pushing HEAD. The second push is a silent no-op but may confuse users who see a push command appear to run without effect. A guard or an explicit note that the first command is a no-op when already pushed in Step 3 would clarify intent.

Prompt To Fix With AI
This is a comment left during a code review.
Path: skills/trunk-first-repo/SKILL.md
Line: 67-84

Comment:
**Step 3a redundantly re-pushes `main:main` when the remote was already set up in Step 3**

When the user provided a remote URL during init, Step 3 already ran `git push -u origin main:main`. Step 3a unconditionally repeats that push before pushing `HEAD`. The second push is a silent no-op but may confuse users who see a push command appear to run without effect. A guard or an explicit note that the first command is a no-op when already pushed in Step 3 would clarify intent.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants