# 🎶🎹🎵 Glockenspiel 🎶🎹🎵

the suno sorta monorepo

## Structure

- [studio_api](/studio_api) - Django API for Discord Bot and Suno Studio
- [suno_utils](/suno_utils) - Toolkit library for ML / audio utilities
- [ui/app-ui](/ui/app-ui) - Suno web app frontend

Other folders are a bit older and not currently used.

## Development

New around here? Welcome! Check out the [dev env setup doc][onboarding]!

### One Click Start in VSCode/Cursor!

Go to Run and Debug (SHIFT-CMD-D). In the dropdown next to the green play button, select Run All.

This will start:

- Tailscale Funnel
- Django Runserver
- NextJS Dev

You can also run each of the above launch actions individually from the dropdown.

### VSCode Tasks

To migrate Django: CMD-P -> >Tasks: Run Tasks -> Django Migrate
To export OpenAPI Schema: CMD-P -> >Tasks: Run Tasks -> Export OpenAPI Schema

### uv

For Python projects, we are working towards managing everything with [uv](https://docs.astral.sh/uv/). Some projects still rely on pdm today.

The main thing to know about uv that differs from previous iterations of Python tooling is that you largely just need one command to setup and run a project: `uv run`. This one command bundles dependency resolution, virtualenv setup, and running python, so you really shouldn't need much beyond this unless changing dependencies. A simple example might be: `uv run manage.py runserver` to run a Django server locally.

Day-to-day basics:

- docs: https://docs.astral.sh/uv/getting-started/
- install uv: `brew install uv`
- **install git hooks (one-time)**: `lefthook install` (or `pnpm install` in ui/app-ui will do this automatically)
- run django stuff: `uv run manage.py ...`
- run tests: `uv run pytest ...`
- run ruff: `uv run ruff .` (lint) or `uv run ruff . --fix` (fix errors)

Probably don't need these, but if you want to manually do these steps:

- create venv: `uv venv` (also occurs when `uv run` is used)
- sync deps: `uv sync` (also occurs when `uv run` is used)

Updating dependencies:

- add/update dependency in relevant project's `pyproject.toml`
- update lockfile (uv.lock): `uv lock`
- output new requirements.txt: `uv pip compile pyproject.toml -o requirements.txt --generate-hashes`

### Mac

Install Docker for Mac.

```
brew install ffmpeg sox
```

[Install PDM](https://pdm.fming.dev/latest/#installation) to manage Python dependencies.

### Ubuntu (e.g. EC2)

```
sudo apt-get install python3-dev build-essential
sudo apt-get install sox libsox-fmt-mp3
python3 -m venv venv

source venv/bin/activate
pip install -e ./suno_utils
pip install -e ./descript-audio-codec
```

[onboarding]: https://docs.google.com/document/d/1JPxW_K-ukAyBr1P2vEJ5HMjH9H1vhtjwuc2Yqgm32VE

## Linear + Claude Code Workflow

_**YOU SHOULD ALWAYS VALIDATE YOUR SOLUTION WORKS BEFORE PUSHING CODE**_

Currently we have a simple workflow to fetch linear tickets via MCP & implement them using Claude Code. Once Claude Code is installed, run `claude` in the directory you want to make changes. To add additional files, you can run `/add-dir`

### Setup

- Setup [Claude Code](https://docs.anthropic.com/en/docs/claude-code/setup)
- Add the Linear MCP server to be able to fetch issues: `claude mcp add --transport sse linear https://mcp.linear.app/sse`
- run `claude` in the terminal (or better yet your [IDE terminal](https://docs.anthropic.com/en/docs/claude-code/ide-integrations))
  - if using the IDE, set up the extension. the cmd+esc hotkeys to start claude & checking change in the terminal is useful
- run `/mcp` -> press `Enter`
- Authenticate Linear via the browser. You should now see MCP under `Authorized applications` in your [settings page] (https://linear.app/sunomusic/settings/account/security)
- Now the Linear MCP server should be added to your local claude setting (`~/.claude.json` under `"mcpServers"`)

#### Revoking MCP Access

If you ever need to revoke Linear / other MCP permissions do the following:

- [Linear]: revoke MCP authorization in your [settings page] (https://linear.app/sunomusic/settings/account/security)
- run `claude mcp list` to see all added mcp servers
- run `claude mcp remove [server_name]` (eg. `claude mcp remove linear`)
- Note: you may need to reauthenticate if you add it again

### Running another Suno app locally

_Note: there are probably better ways to do this (tbd)_

This is how you can create another workspace for claude code to do it's thang while you run your main repo

- Go to ~
- Make another copy of the glockenspiel repo (`git clone https://github.com/suno-ai/glockenspiel.git glockenspiel-claude`)
- cd into glockenspiel-claude
  - [BE server] Setup aws sso to get env variables or copy over your .env from the primary repo
  - [FE server] Copy over your .env.local from the primary repo
- Run the python server using a specific port other than 8000 (default): `uv run manage.py runserver 8001`
  - Replace the default ports to the new port (eg `:8000` -> `:8001`)
- Run the FE server `pnpm install && pnpm dev`
  - if you have another next.js server running, it should increment the port accordingly (eg. run on `localhost:3001` instead of `localhost:3000`)

### Claude Commands

[Custom Claude commands](https://docs.anthropic.com/en/docs/claude-code/common-workflows#create-custom-slash-commands) are a useful way to save workflows / prompts to reuse. These can be found under `.claude/commands`

One useful workflow can look like:

- `/project:fix-issue [LINEAR-ISSUE]`: fetches a linear issue and starts working on it
- Continue prompting and iterate until getting to a solution
- Validate your solution through tests / local dev server
- **Review your code**
- `/project:pr` to create a pr

### Tips

- Setup notifications in your terminal for when claude output is ready: [docs](https://docs.anthropic.com/en/docs/claude-code/setup#notification-setup) (there are probably ways to customize this)

### References

- [Claude Code Docs](https://docs.anthropic.com/en/docs/claude-code/overview)
- [Claude Code Best Practices](https://www.anthropic.com/engineering/claude-code-best-practices)
