Skip to content

docs(lessons): add absolute-paths and git-commit-format workflow lessons#74

Closed
TimeToBuildBob wants to merge 1 commit intomasterfrom
feat/add-workflow-lessons
Closed

docs(lessons): add absolute-paths and git-commit-format workflow lessons#74
TimeToBuildBob wants to merge 1 commit intomasterfrom
feat/add-workflow-lessons

Conversation

@TimeToBuildBob
Copy link
Copy Markdown
Member

Summary

Adds two workflow lessons to the template's lessons/workflow/ directory, based on LOO (leave-one-out) effectiveness analysis from Bob's workspace:

  • absolute-paths-for-workspace-files (Δ=+0.198 session reward, p<0.001): Always use absolute paths when writing workspace files. Prevents journal entries and other files from being created in the wrong directory when working across multiple repos.

  • git-commit-format (Δ=+0.162 session reward, p<0.001): Conventional Commits format for all commit messages. Keeps git history clean and scannable.

Neither lesson is currently in gptme-contrib/lessons/workflow/, so new agents created from this template were missing both. The template's own lessons/workflow/ directory was empty before this PR.

Why these two?

From LOO effectiveness analysis (scripts/lesson-loo-analysis.py --category-controlled), these are the top two lessons by session reward improvement that are NOT already in gptme-contrib. Adding them to the template ensures every new agent benefits from day one.

Test plan

  • Pre-commit hooks pass (lessons validated)
  • Lesson format matches markdown-codeblock-syntax.md style
  • Keywords are specific multi-word phrases (not single words)

These two lessons have the highest positive impact on session reward
from LOO (leave-one-out) effectiveness analysis on Bob's workspace:
- absolute-paths-for-workspace-files (Δ=+0.198, p<0.001)
- git-commit-format (Δ=+0.162, p<0.001)

Neither lesson is currently in gptme-contrib/lessons/, so new agents
created from this template were missing both. Adding them to the
template's own lessons/workflow/ ensures all new agents start with
these high-value behavioral constraints.

Co-authored-by: Bob <bob@superuserlabs.org>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR adds two new workflow lessons to the lessons/workflow/ directory — absolute-paths-for-workspace-files.md and git-commit-format.md — which were identified as the top two highest-impact missing lessons from a LOO effectiveness analysis. The git-commit-format lesson is clean and well-structured. The absolute-paths-for-workspace-files lesson has a meaningful logic flaw in its pattern example that undermines the rule it teaches, and a broken link to a companion doc that was not created.

Key findings:

  • The "correct" shell example in absolute-paths-for-workspace-files.md uses git rev-parse --show-toplevel to derive the workspace path, but this still resolves relative to the current git repo — the exact failure mode the lesson is meant to prevent. The inline save-tool example beneath it is actually the correct approach and should be the primary demonstration.
  • The Related section of absolute-paths-for-workspace-files.md references a companion doc (knowledge/lessons/workflow/absolute-paths-for-workspace-files.md) that does not exist in the repository and is not created in this PR.
  • Both lessons use YAML block-sequence syntax for keywords in their frontmatter, while TEMPLATE.md specifies inline list syntax — a minor inconsistency that could affect frontmatter validators.
  • Both lessons use documentation-style imperative framing rather than the project's preferred agent-benefit framing for instructions.

Confidence Score: 2/5

  • Not safe to merge as-is — the primary lesson contains a pattern example that is logically incorrect and would teach agents the wrong approach.
  • The git-commit-format lesson is solid, but the absolute-paths-for-workspace-files lesson has a P1 logic error where the "correct" git rev-parse --show-toplevel example actually replicates the failure it claims to fix. Since the entire purpose of this lesson is to prevent file misplacement, shipping an incorrect "correct" example would actively mislead agents. The dead companion-doc link is also a broken reference in the final artifact.
  • lessons/workflow/absolute-paths-for-workspace-files.md requires attention for the logic error in the pattern example and the dead companion-doc link.

Important Files Changed

Filename Overview
lessons/workflow/absolute-paths-for-workspace-files.md New workflow lesson for absolute paths. Contains a logical error in the shell pattern example: git rev-parse --show-toplevel still ties the path to the current repo, which doesn't fix the cross-repo failure scenario the lesson describes. Also has a dead link to a non-existent companion doc.
lessons/workflow/git-commit-format.md New workflow lesson for Conventional Commits format. Content is accurate and examples are helpful. Minor style issues: frontmatter format differs from TEMPLATE.md and framing is documentation-style rather than agent-benefit-focused.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent writes a file] --> B{Path type?}
    B -->|Relative path| C[Resolve against CWD]
    C --> D{CWD = agent workspace?}
    D -->|Yes| E[✅ File lands correctly]
    D -->|No - changed dir| F[❌ File lands in wrong repo]
    B -->|git rev-parse toplevel| G[Resolve against current git root]
    G --> H{Current repo = agent workspace?}
    H -->|Yes| E
    H -->|No - in external repo| F
    B -->|Hardcoded absolute path| I[Always resolves to fixed location]
    I --> E
Loading

Last reviewed commit: "docs(lessons): add a..."

Comment on lines +33 to +37

# ✅ Correct: absolute path works from any directory
WORKSPACE=$(git rev-parse --show-toplevel)
echo "..." >> "$WORKSPACE/journal/2025-10-14-topic.md"
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 "Correct" pattern still resolves relative to current repo

The suggested fix using git rev-parse --show-toplevel does not solve the problem this lesson is meant to prevent. If the agent has already cd'd into an external repo (the exact failure scenario described), git rev-parse --show-toplevel returns the root of that repo — not the agent workspace. The file would still land in the wrong location.

The rule itself is correct ("always use absolute paths"), but the shell example undermines it by deriving the path from the current git context rather than using a hardcoded or pre-established absolute path. The second example further down with a literal /home/agent/workspace/... path is actually the correct approach.

Consider replacing the shell example with something like:

# ❌ Wrong: relative path depends on cwd
cd ~/projects/gptme
echo "..." >> journal/2025-10-14-topic.md  # creates in wrong repo!

# ❌ Also wrong: still depends on current git repo
WORKSPACE=$(git rev-parse --show-toplevel)
echo "..." >> "$WORKSPACE/journal/2025-10-14-topic.md"

# ✅ Correct: hardcoded absolute path to agent workspace
echo "..." >> "/home/agent/workspace/journal/2025-10-14-topic.md"

- **No confusion**: Explicit about which repo/workspace receives the file

## Related
- Full context: knowledge/lessons/workflow/absolute-paths-for-workspace-files.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Dead link to companion doc

The Related section links to knowledge/lessons/workflow/absolute-paths-for-workspace-files.md, but this companion file is not created in this PR and does not exist in the repository. Per the README, companion docs are optional — if there is no companion doc, this line should be removed rather than pointing to a non-existent file.

Suggested change
- Full context: knowledge/lessons/workflow/absolute-paths-for-workspace-files.md
## Related
- [Conventional Commits Specification](https://www.conventionalcommits.org/)

Or simply omit the Related section body if there are no valid links.

Comment on lines +1 to +11
---
match:
keywords:
- "save file to"
- "write journal entry"
- "mkdir -p journal"
- "file path"
- "wrong directory"
- "file ended up in wrong"
- "journal created in external repo"
status: active
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Frontmatter format inconsistent with TEMPLATE.md

TEMPLATE.md uses an inline list for keywords:

match:
  keywords: ["keyword1", "keyword2", "specific phrase"]

Both new lessons use YAML block sequence style (dashes). While both are valid YAML, the inconsistency with the template may cause issues with pre-commit validators that parse the frontmatter with specific format expectations. The same applies to lessons/workflow/git-commit-format.md (lines 1–12).

Suggested change
---
match:
keywords:
- "save file to"
- "write journal entry"
- "mkdir -p journal"
- "file path"
- "wrong directory"
- "file ended up in wrong"
- "journal created in external repo"
status: active
---
match:
keywords:
- "save file to"
- "write journal entry"
- "mkdir -p journal"
- "file path"
- "wrong directory"
- "file ended up in wrong"
- "journal created in external repo"
status: active
---

Consider aligning with the template format:

---
match:
  keywords: ["save file to", "write journal entry", "mkdir -p journal", "file path", "wrong directory", "file ended up in wrong", "journal created in external repo"]
status: active
---

Comment on lines +14 to +16
## Rule
All commit messages must follow Conventional Commits format with a type prefix, optional scope, and short description.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Agent-benefit framing not used

Per the project's writing guidelines for tool/agent instructions, the rule and context sections should be framed in terms of how following this pattern benefits the agent and enhances its capabilities, rather than as a documentation-style imperative. The current phrasing ("All commit messages must follow…", "When creating git commits…") reads as external documentation rather than agent-centric guidance.

For example:

Suggested change
## Rule
All commit messages must follow Conventional Commits format with a type prefix, optional scope, and short description.
## Rule
Use Conventional Commits format to keep history scannable, enable automated changelogs, and signal the nature of your change at a glance.
## Context
Every time you create a git commit, this format helps reviewers — and your future self — quickly understand what changed and why.

The same applies to the absolute-paths-for-workspace-files.md lesson (## Rule and ## Context sections).

Rule Used: When writing tool instructions, focus on how the s... (source)

Learnt From
gptme/gptme#722

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!

@ErikBjare
Copy link
Copy Markdown
Member

Shouldn't these lessons go in gptme-contrib instead?

@TimeToBuildBob
Copy link
Copy Markdown
Member Author

You're right. These are generic lessons that should benefit all agents via gptme-contrib, not just new ones from the template.

Closing this. Will create a gptme-contrib PR instead with properly generalized versions (the absolute-paths lesson hardcodes Bob's path, and the commit-format lesson includes Bob-specific co-authorship that needs to be stripped).

@TimeToBuildBob
Copy link
Copy Markdown
Member Author

Follow-up: created gptme/gptme-contrib#507 with properly generalized versions:

  • Fixed the git rev-parse --show-toplevel logic error (it resolves to current git root, not workspace — same failure mode as relative paths)
  • Removed agent-specific co-authorship note from commit-format lesson

@TimeToBuildBob TimeToBuildBob deleted the feat/add-workflow-lessons branch March 27, 2026 20:58
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