Skip to content

Latest commit

 

History

History
108 lines (84 loc) · 4.05 KB

File metadata and controls

108 lines (84 loc) · 4.05 KB

<main_goal> Rapid GitHub Repo Clone & Push Workflow Goal: Quickly clone a GitHub repository (without history) and push it to a new repository under one of your organizations, then open it in Cursor. Prerequisites Node.js (for running npx commands). GitHub CLI (gh) – installed and authenticated (run gh auth login once beforehand) stackoverflow.com . Git – installed for initializing and pushing the repo. Cursor – the cursor command is available in your PATH (for opening the project). Automated Shell Script Below is a bash script that automates the entire process. You can save this as fast-clone.sh and run it, or execute the commands step-by-step in a terminal. Comments explain each step: bash Copy #!/bin/bash

Usage: ./fast-clone.sh [target-dir]

can be a GitHub URL or "owner/repo" shorthand.

[target-dir] is optional (default: ~/project).

1. Set target directory (default to ~/project if not provided)

TARGET_DIR="${2:-$HOME/project}"

2. Clone the GitHub repository quickly using npx giget(no git history for speed)

- giget uses a tarball download for fast cloning:contentReference[oaicite:1]{index=1}.

SOURCE_REPO="$1" if [ -z "$SOURCE_REPO" ]; then read -p "Enter GitHub repository (URL or owner/repo): " SOURCE_REPO fi echo "Cloning $SOURCE_REPO into $TARGET_DIR ..." npx --yes giget "$SOURCE_REPO" "$TARGET_DIR" --force || exit 1

(Tip: replace npx giget with ` if you prefer that tool.)

3. Initialize a new git repository and commit all files

cd "$TARGET_DIR" || exit 1 git init git add . git commit -m "Initial commit"

4. Ensure GitHub CLI is logged in

gh auth status &>/dev/null || gh auth login

5. Prompt user to select one of their GitHub organizations for the new repo

echo "Fetching your organizations..."

Get list of org logins (requires gh CLI v2.28+ for 'gh org list')

mapfile -t ORGS < <(gh org list --limit 100 | tail -n +2 | awk '{print $1}')

If gh org list isn't available or returns nothing, fall back to GitHub API:

if [ ${#ORGS[@]} -eq 0 ]; then mapfile -t ORGS < <(gh api /user/orgs --jq '.[].login') fi echo "Select an organization for the new repository:" select ORG in "${ORGS[@]}"; do if [[ -n "$ORG" ]]; then break; fi done

6. Prompt for new repository name

read -p "Enter a name for the new GitHub repository: " NEW_REPO

7. Create the new repository under the selected org and push the local code

(Using --source and --push to auto-add remote and upload):contentReference[oaicite:3]{index=3}

gh repo create "$ORG/$NEW_REPO" --private --source=. --remote=origin --push

8. Open the project in Cursor

cursor . Notes: The script uses npx giget to download the repository content quickly (without git history) github.com github.com . TARGET_DIR defaults to ~/project but can be changed by providing a second argument or editing the script. The GitHub CLI command with --source=. --push creates a new repo under the chosen organization and immediately pushes your initial commit to it (equivalent to gh repo create ORG/REPO followed by a push) stackoverflow.com . The cursor . command opens the current project directory in the Cursor editor – ensure you have Cursor installed and its CLI in your PATH. """ </main_goal>

above you can see our <main_goal>

  1. all our cli commands will be placed inside src/commands

commands: init.ts (to initialize a project) with options you can choose from

  • project name

  • project directory: where project should be stored (defaults to ~/projects//)

  • enter a name for new github rpeo (default is project-name plus a )

  • which ide you're using (sets the start command in a map code . -> visual studio code cursor . -> cursor windsurf . -> windsurf )

  • more needed?

  1. also add commands without having an interactive mode - just with flags if we quickly want to scaffold something.

  2. build the logic of the cli but use a different .ts file for it like so code is separated from the cli logic if we want to reuse it (probaby later in a model context protocol server)

there are some options which needs to be dynamic