Skip to content

feat(templates): add branch declaration field to session log template #685

@rjmurillo-bot

Description

@rjmurillo-bot

Summary

Update session log template to require explicit branch declaration, improving agent awareness and enabling branch verification.

Background

From PR co-mingling retrospective (PR #669): Agents lacked branch awareness during multi-PR sessions. Requiring explicit branch declaration in session logs improves visibility and enables verification gates.

Priority: P1 (Improves awareness, supports #684 verification)

Specification

Skill ID: session-init-003
Atomicity: 82%
Category: Session initialization

Template Changes

Current Template (implied)

# Session NNN: [Title]

**Date**: YYYY-MM-DD
**Agent**: [agent-name]

## Objective
[...]

New Template (with branch)

# Session NNN: [Title]

**Date**: YYYY-MM-DD
**Agent**: [agent-name]
**Branch**: [REQUIRED - output of 'git branch --show-current']
**PR**: #NNN (if applicable)

## Objective
[...]

Session Initialization

# During session start (after Serena activation)
$branch = git branch --show-current
$sessionLog = ".agents/sessions/$(Get-Date -Format 'yyyy-MM-dd')-session-$NN.md"

# Populate template with branch
$template = Get-Content ".agents/templates/session-log.md"
$template = $template -replace '\*\*Branch\*\*: \[REQUIRED.*\]', "**Branch**: $branch"
$template | Set-Content $sessionLog

Implementation

Files to Update

  1. Template file (if exists): .agents/templates/session-log.md
  2. SESSION-PROTOCOL.md: Document branch declaration requirement
  3. Validate-SessionEnd.ps1: Verify branch field exists and matches current branch

Validation Logic

# In Validate-SessionEnd.ps1
$sessionLog = Get-Content $SessionLogPath -Raw
if ($sessionLog -notmatch '\*\*Branch\*\*:\s+(.+)') {
    Write-Error "Session log missing required branch declaration"
    exit 1
}

$declaredBranch = $Matches[1].Trim()
$currentBranch = git branch --show-current

if ($declaredBranch -ne $currentBranch) {
    Write-Warning "Branch changed during session: declared=$declaredBranch, current=$currentBranch"
}

Testing

  • New session logs include branch field
  • Validate-SessionEnd.ps1 checks for branch declaration
  • Validation warns on branch mismatch
  • Template propagates to all agent prompts

Related

Acceptance Criteria

  • Session log template includes Branch field
  • SESSION-PROTOCOL.md documents branch declaration requirement
  • Validate-SessionEnd.ps1 checks branch field exists
  • Validation warns on branch mismatch (declared != current)
  • Agent prompts updated to populate branch field

Impact

Improves agent awareness of branch context, supports #684 verification gates, and provides audit trail for branch usage during sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-qaTesting and verification agentagent-retrospectiveLearning extraction agentarea-promptsAgent prompts and templatesarea-skillsSkills documentation and patternsarea-workflowsGitHub Actions workflowsautomationAutomated workflows and processesbugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or requestpriority:P1Important: Affects user experience significantly, high business value

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions