I like my Git branch names to start with the GitHub issue number that I'm working on and then have a sensible description (usually based on the GitHub issue name).

For example:

First material transaction in time card pre-approval form is incorrect #4045



And so I made an Alfred workflow (right-click to download) that takes the GitHub issue name and number and creates a Git branch name that's usually good enough.

Here's the good-enough JavaScript that does the conversion.

function run(argv) {
  const SEP = '-';
  const MAX_LENGTH = 50;
  const NUMBER_PATTERN = /\d+$/;
  const SUFFIX_PATTERN = /\s*#\d+$/;
  const WORD_SEPARATOR_PATTERN = /[\s\(\)]+/g;

  let [query] = argv;
  let numberMatches = query.match(NUMBER_PATTERN);
  if (numberMatches) {
    let [number] = numberMatches;
    let parts = [number];
    let name = query.replace(SUFFIX_PATTERN, '');
    let words = name.split(WORD_SEPARATOR_PATTERN);
    while (words.length > 0) {
      let word = words.shift().toLowerCase();
      if (parts.join(SEP).length + word.length + number.length < MAX_LENGTH) {
        parts.splice(-1, 0, word);
      } else {
    return parts.join(SEP);


  • v1.1 updated the WORD_SEPARATOR_PATTERN to remove additional characters