-
Notifications
You must be signed in to change notification settings - Fork 0
V0.7.5/trunk first repo #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| --- | ||
| name: trunk-first-repo | ||
| description: > | ||
| Initialize a folder as a git repository following scaled trunk-based development. Sets up an empty main branch (seed commit only), creates a versioned feature branch, and enforces a PR-first workflow where content only reaches main through pull requests. Use this skill when the user wants to initialize a git repo, set up a new repository, start a project with proper git workflow, or mentions "trunk-based", "PR workflow", "branch protection", "git init", or wants to follow GitHub PR best practices. ALWAYS use this skill when asked to initialize or set up a git repository. | ||
| description: > | ||
| Initialize a folder as a git repository following scaled trunk-based development. Sets up an empty main branch (seed commit only), creates a versioned feature branch, pushes main before feature branches, and enforces a PR-first workflow where content only reaches main through pull requests. Use this skill when the user wants to initialize a git repo, set up a new repository, start a project with proper git workflow, safely push the first trunk-first branches later with "push remote", or mentions "trunk-based", "PR workflow", "branch protection", "git init", or wants to follow GitHub PR best practices. ALWAYS use this skill when asked to initialize or set up a git repository. | ||
| --- | ||
|
|
||
| # Trunk-First Repo | ||
|
|
@@ -12,9 +12,17 @@ Initialize a folder as a git repository following [scaled trunk-based developmen | |
|
|
||
| This matters because it prevents accidental pushes to main, establishes a clean PR-based workflow from day one, and makes the git history meaningful by design rather than as an afterthought. | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### Step 1: Collect Parameters | ||
| ## Workflow | ||
|
|
||
| ### Step 0: Select Mode | ||
|
|
||
| If the user says `push remote`, do not initialize the repository again. Use the Push Remote Workflow below. | ||
|
|
||
| Otherwise, use the Initialize Workflow. | ||
|
|
||
| ## Initialize Workflow | ||
|
|
||
| ### Step 1: Collect Parameters | ||
|
|
||
| Read `FORMS.md` and collect all parameters by presenting each field to the user one at a time using the agent's native input mechanism. Follow the presentation rules defined in the form. Do not proceed to Step 2 until all required fields are collected and the user confirms the summary. | ||
|
|
||
|
|
@@ -46,15 +54,46 @@ After step 5, the user is on the feature branch (e.g. `v0.1.0/init`) with all th | |
| If the user provided a remote URL: | ||
|
|
||
| ```bash | ||
| git remote add origin {REMOTE_URL} | ||
| git push -u origin main | ||
| ``` | ||
|
|
||
| If skipped, remind the user they can add it later: | ||
|
|
||
| > When you're ready, run: `git remote add origin <url>` followed by `git push -u origin main` | ||
|
|
||
| ### Step 4: Summary | ||
| git remote add origin {REMOTE_URL} | ||
| git push -u origin main:main | ||
| ``` | ||
|
|
||
| Run the push while still on the feature branch. Do not switch to `main` just to push it; Git can push the branch ref by name without changing the working tree. | ||
|
|
||
| If skipped, remind the user they can add it later: | ||
|
|
||
| > When you're ready, invoke this skill with `push remote <url>` from the feature branch, or run `git remote add origin <url>` followed by `git push -u origin main:main` | ||
|
|
||
| ### 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. | ||
|
Comment on lines
+67
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 Consider cross-referencing the Push Remote Workflow for this case, or mirroring the Step P1 checks inline. Prompt To Fix With AIThis 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. |
||
|
|
||
| ### Step 4: Summary | ||
|
|
||
| After initialization, display a summary: | ||
|
|
||
|
|
@@ -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 | ||
| ``` | ||
|
Comment on lines
96
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Step 4 always renders 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 Prompt To Fix With AIThis 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. |
||
|
|
||
| ## Push Remote Workflow | ||
|
|
||
| Use this workflow when the user invokes `push remote`, especially when the remote URL was not available during initialization. | ||
|
|
||
| ### Step P1: Confirm Current State | ||
|
|
||
| Inspect the current branch: | ||
|
|
||
| ```bash | ||
| git branch --show-current | ||
| ``` | ||
|
|
||
| If the current branch is `main`, stop and ask the user to switch to the feature branch first. Do not push the first feature branch while checked out on `main`. | ||
|
|
||
| Verify `main` is still the empty seed branch: | ||
|
|
||
| ```bash | ||
| git ls-tree -r --name-only main | ||
| ``` | ||
|
|
||
| Empty output is expected. If output is not empty, stop and explain that `main` already contains files, so this is no longer the empty trunk-first seed state. | ||
|
|
||
| When explaining this check, explicitly say that untracked or ignored files can remain visible in the checkout directory but are not part of `main` unless they appear in `git ls-tree -r --name-only main`. | ||
|
|
||
| ### Step P2: Resolve Remote | ||
|
|
||
| Check whether `origin` already exists: | ||
|
|
||
| ```bash | ||
| git remote get-url origin | ||
| ``` | ||
|
|
||
| If `origin` exists, use it. | ||
|
|
||
| If `origin` does not exist and the user provided a URL after `push remote`, add it: | ||
|
|
||
| ```bash | ||
| git remote add origin {REMOTE_URL} | ||
| ``` | ||
|
|
||
| If `origin` does not exist and the user did not provide a URL, ask for the remote URL before proceeding. Do not guess or use a placeholder. | ||
|
|
||
| ### Step P3: Push in Safe Order | ||
|
|
||
| Run these commands from the feature branch: | ||
|
|
||
| ```bash | ||
| git push -u origin main:main | ||
| git push -u origin HEAD | ||
| ``` | ||
|
|
||
| Do not switch to `main` just to push it. Git can push the `main` branch ref by name while the checkout stays on the feature branch. | ||
|
|
||
| After pushing, tell the user to open a PR from the pushed feature branch to `main`. | ||
|
|
||
| ## Conventions | ||
|
|
||
|
|
@@ -99,11 +195,12 @@ The version prefix groups branches by project maturity. The context should be sh | |
|
|
||
| Once initialized, the day-to-day workflow is: | ||
|
|
||
| 1. **Create a feature branch** from main: `git checkout -b v0.1.0/my-feature main` | ||
| 2. **Work and commit** on the feature branch | ||
| 3. **Push and open a PR** to main | ||
| 4. **Review, approve, and merge** the PR | ||
| 5. **Delete the feature branch** after merge | ||
| 6. **Pull main** and create the next feature branch | ||
| 1. **Create a feature branch** from main: `git checkout -b v0.1.0/my-feature main` | ||
| 2. **Work and commit** on the feature branch | ||
| 3. **Push main by ref if the remote does not have it yet**: `git push -u origin main:main` | ||
| 4. **Push the feature branch and open a PR** to main: `git push -u origin HEAD` | ||
| 5. **Review, approve, and merge** the PR | ||
| 6. **Delete the feature branch** after merge | ||
| 7. **Pull main** and create the next feature branch | ||
|
|
||
| Feature branches should be short-lived — ideally merged within hours or a few days, not weeks. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main:mainwhen the remote was already set up in Step 3When 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 pushingHEAD. 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
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!