Skip to content

Ctx measurement example#43

Merged
AchintyaAshok merged 7 commits into
mainfrom
ctx-measurement-example
Sep 30, 2025
Merged

Ctx measurement example#43
AchintyaAshok merged 7 commits into
mainfrom
ctx-measurement-example

Conversation

@AchintyaAshok
Copy link
Copy Markdown
Contributor

@AchintyaAshok AchintyaAshok commented Sep 30, 2025

Description

This PR adds documentation for the context measurement feature, creates two new slash commands for PR and release management automation, and includes supporting assets. The context measurement feature helps users understand token usage per tool to optimize their toolsets. The new automation commands streamline the PR creation workflow and release notes generation process.

Type of Change

Please check the relevant option(s):

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧪 Test improvement
  • 🔧 Build/tooling improvement
  • 🎨 Code refactoring

Changes Made

New Features

Added /proj:create-pr slash command for complete PR workflow

  • Runs just pr-prep to validate all CI checks locally
  • Rebases from main to ensure branch is up-to-date
  • Pushes branch to remote (with -u flag if needed)
  • Creates PR on GitHub with gh pr create
  • Generates comprehensive PR description from commits
  • Updates PR with formatted description following template
  • Includes safety checks for uncommitted changes, branch verification
  • Smart branch name to PR title conversion
  • Location: .claude/commands/proj/create-pr.md

Added /proj:generate-release-notes slash command

  • Updates latest existing release (not creates new)
  • Finds all commits between previous release and latest release
  • Handles multiple version tags between releases (e.g., v0.0.41-44 captured in v0.0.45 release)
  • Fetches PR details via gh CLI and categorizes by type
  • Generates formatted release notes following RELEASE_NOTES_TEMPLATE.md
  • Includes overview, highlights, contributors, and full changelog links
  • Backs up previous release notes before updating
  • Location: .claude/commands/proj/generate-release-notes.md

Added Release Notes Template

  • Comprehensive template structure for consistent release documentation
  • Sections for all change types (features, bugs, docs, build/tooling, etc.)
  • Breaking changes with migration guides
  • Contributors and statistics
  • Installation and feedback sections
  • Location: .github/RELEASE_NOTES_TEMPLATE.md

Bug Fixes

Fixed generate-release-notes command clarifications

  • Clarified that command UPDATES existing release (not creates new)
  • Added logic to handle multiple version tags between releases
  • Uses gh release list to find actual releases (not just git tag)
  • Example: v0.0.45 release includes changes from v0.0.41-44 if v0.0.40 was previous release
  • Updated example commands and documentation

Added assets for context measurement feature

  • Added screenshots showing token usage per tool
  • assets/toolset_context.png - Active toolset with context info
  • assets/all_tools_context.png - All available tools with token estimates

Other Enhancements

Updated README with context measurement documentation

  • Added Context Measurement section after Personas with screenshot
  • Explains benefits: optimize context usage, make informed decisions, compare alternatives
  • Shows usage via MCP tools (list-available-tools, get-active-toolset)
  • Added link to awesome-mcp-personas repository
  • Added two FAQ entries about token estimate accuracy and performance impact
  • Updated All Features table with context measurement entry
  • Fixed hallucinated API reference (context measurement uses MCP tools, not HTTP API)

Security improvements in /proj:create-pr command

  • Restricted git remote permissions from wildcard git remote* to specific commands
  • Now allows only: git remote -v, git rev-parse --abbrev-ref @{upstream}
  • Added explicit permissions for git pull --rebase origin main and git status --porcelain
  • Added rebase step as Step 2 to ensure branch is always up-to-date before PR creation

Breaking Changes

None - all changes are additions and documentation improvements.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested the changes with both stdio and HTTP transports

Testing performed:

  • Ran just pr-prep successfully - all checks passed (pre-commit, build, tests, typecheck, lint, format)
  • Verified slash commands are properly documented with allowed-tools lists
  • Confirmed README renders correctly with screenshots and links
  • Tested this PR creation using /proj:create-pr command itself

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have run npm run lint and npm run format
  • I have run the test suite with npm test
  • Any dependent changes have been merged and published

Screenshots

Context measurement feature in action:

Toolset Context View
Active toolset showing token usage per tool

Related Issues

N/A - These are proactive improvements to documentation and developer workflow automation.

Additional Notes

Key workflow improvements:

  • /proj:create-pr provides end-to-end PR creation: validate → rebase → push → create → generate description
  • /proj:generate-release-notes automates release notes generation from merged PRs across multiple version tags
  • Both commands use gh CLI and follow security best practices with specific allowed-tool permissions

Documentation improvements:

  • Context measurement feature now properly documented in README with real screenshots
  • Links to awesome-mcp-personas for easy persona discovery
  • FAQ entries address accuracy and performance concerns

Future enhancements:

  • Consider adding --dry-run flag to /proj:create-pr to preview changes without pushing
  • Could extend /proj:generate-release-notes to support custom release note templates
  • May want to add validation for changelog format consistency

This PR was created using /proj:create-pr itself! 🚀

…late

Added new slash command:
- /proj:generate-release-notes - Automatically generates release notes from merged PRs
- Finds commits between releases
- Extracts PR numbers from squash/merge commits
- Fetches PR details via gh CLI
- Categorizes changes by type (features, bugs, docs, etc.)
- Generates formatted release notes from template
- Backs up and updates GitHub release

Added release notes template:
- .github/RELEASE_NOTES_TEMPLATE.md - Comprehensive template structure
- Includes sections for all change types
- Breaking changes with migration guides
- Contributors and statistics
- Full changelog links
- Installation and feedback sections

Features:
- Automated PR discovery and categorization
- Rich formatting with emojis for visual scanning
- Backup/revert capability
- Handles edge cases (first release, direct commits, etc.)
- Links to PRs, issues, and compare views
… multiple tags

Critical clarifications:
- Command UPDATES the latest existing release (not creates new)
- Handles multiple version tags between releases
- Uses gh release list to find actual releases (not git tag)
- Example: v0.0.44 release may include changes from v0.0.41-v0.0.44 if v0.0.40 was previous release
- Captures all commits between previous RELEASE and latest RELEASE

Key changes:
- Step 1: Clarified we update existing release, not create new
- Step 1: Added logic to find previous actual release (may skip tags)
- Step 2: Changed to capture ALL commits, not just merges
- Step 6: Emphasized UPDATE vs create
- Example Usage: Shows realistic scenario with skipped tags
- Handling Edge Cases: Added "Multiple Tags Between Releases" section
- Example Commands: Updated to show release list and commit range
- Added Context Measurement section after Personas with screenshot
- Explains benefits: optimize context usage, make informed decisions, compare alternatives, budget context
- Shows usage via MCP tools (list-available-tools, get-active-toolset)
- Added link to awesome-mcp-personas repository
- Added two FAQ entries about token estimate accuracy and performance impact
- Kept personas section intact as requested
- Updated All Features table with context measurement entry
New command: /proj:create-pr
- Runs just pr-prep to validate CI checks locally
- Pushes branch to remote (with -u flag if needed)
- Creates PR on GitHub with gh CLI
- Generates comprehensive PR description from commits
- Updates PR with formatted description

Features:
- Complete end-to-end PR creation workflow
- Safety checks: verifies branch, checks for uncommitted changes
- Error handling for push failures, existing PRs, auth issues
- Automatic backup of existing PR descriptions
- Smart branch name to PR title conversion
- Reuses PR description generation logic from generate-pr-desc

Allowed tools:
- just pr-prep for local validation
- git commands for branch/push operations
- gh pr commands for PR creation and updates
- File operations for description generation

Comparison with generate-pr-desc:
- create-pr: Full workflow from local branch to PR with description
- generate-pr-desc: Just updates description of existing PR

Usage: /proj:create-pr (from feature branch with committed changes)
Changes to create-pr command:
- Added Step 2: Rebase from main (git pull --rebase origin main)
- Ensures branch is up-to-date before creating PR
- Handles rebase conflicts with clear error messages
- Updated step numbers (Push is now Step 4, Create PR is Step 5, etc.)

Security improvements:
- Replaced wildcard 'git remote*' with specific allowed commands
- Now allows only: 'git remote -v' and 'git rev-parse --abbrev-ref @{upstream}'
- Added explicit permission for 'git pull --rebase origin main'
- Added explicit permission for 'git status --porcelain'

Error handling:
- Added rebase conflict handling instructions
- User must resolve conflicts manually and run git rebase --continue
- Updated example output to show rebase step

Safety:
- Never skip rebase - always ensure up-to-date with main
- Prevents PR conflicts and merge issues
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 30, 2025

🤖 Changeset Status

⚠️ No changeset found - This PR will default to patch version when merged.

Is this the right version bump?

  • 🐛 Bug fixes, small improvements → Automatic patch is perfect! ✅
  • New features, API additions → Consider adding a minor changeset
  • 💥 Breaking changes → Please add a major changeset

How to add a changeset:

  1. Run npx changeset in your terminal
  2. Select the appropriate version bump (patch/minor/major)
  3. Write a short description of your changes
  4. Commit the generated .changeset/*.md file

Skip release entirely:

Add [skip-ci] to your PR title if this shouldn't trigger any release.


This comment will update automatically when you push changes.

- Added --reviewer toolprint/admins flag to gh pr create
- Automatically assigns toolprint/admins team as reviewers on PR creation
- Updated documentation to reflect automatic reviewer assignment
@AchintyaAshok AchintyaAshok requested a review from a team September 30, 2025 19:34
@AchintyaAshok AchintyaAshok merged commit 17784d3 into main Sep 30, 2025
5 checks passed
@AchintyaAshok AchintyaAshok deleted the ctx-measurement-example branch September 30, 2025 19:36
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.

1 participant