Everyday, I switch between tickets, this is chanllenging to maintain ticket focused context with Claude. The trick is to use claude --name <session_name>, in this case the git branch name is a good candidate
Using a shell script to automate this (written by Claude):
#!/bin/bash
branch=$(git branch --show-current 2>/dev/null)
if [ -z "$branch" ]; then
echo "Not a git repository or no branch checked out." >&2
exit 1
fi
echo "session name: $branch"
exec claude --name "$branch" "$@"
I have also created a new Claude skill to prepare the context for the ticket, /prep-ticket
What this does is that it asks Claude to read the ticket info from Gitlab issue via API without the need of MCP
---
name: prep-ticket
description: Given the ticket details provided by the user, perform analysis of the project against the ticket details and create a plan of execution
---
1. Ask the user to provide the ticket details
2. If there are existing commits in the branch, analyse what's been done
3. Understand the ticket details, If user pasted gitlab ticket url, workout the api url and fetch ticket content by using the gitlab token in ~/.claude/gitlab-token file.
4. Figure out how the ticket details is relevant to the project and which parts of the project is related
5. Perform deeper analyse the related code in the project
6. Work out the plan of execution
7. Write down the anaylsis and plan to a file inside folder .ticket_mds in the project, create the folder if it doesn't exists yet and add that folder to the .gitignore file, the filename should be the same as the branch name
# IMPORTANT
Mask the token value in console which read from the gitlab-token file