c/agents › command
0votes

Set up Claude Code in an existing repo

PromptLow risk Tested
submitted by CommandVault editors to c/agents · 3 uses

A first-session prompt that has Claude Code explore your repo and create CLAUDE.md, commands and settings.

Prompt · 1 variable
This is our first session in this repo. Set yourself up properly before any feature work.

1. Explore: read the README, package/build files, CI config and the main folders. Run the test command once to see the current state.
2. Create `CLAUDE.md` with: project summary, exact commands, where things live, conventions, never-do list, definition of done. Only include what you verified about this repo; don't copy rules from your own personal or global instructions.
3. Suggest 3 slash commands in `.claude/commands/` that would save time in this repo (e.g. /test-file, /review) and write them. If you can't write a file, print its full contents in your reply instead.
4. Propose `.claude/settings.json` permissions (show the JSON; don't write the file unless I say so): which commands are safe to always allow ({{safe_commands}}) and which should always ask.
5. Report: what you created, what you couldn't verify, and the 3 biggest risks you noticed in the codebase.
0 commentsreport

Guide

What you get: After one session the repo has a CLAUDE.md with verified commands, three slash commands in .claude/commands/, a .claude/settings.json permission split, and a report of what couldn't be verified and the top 3 risks. Best for Teams starting to use Claude Code in a repo that has no Claude setup yet..

Before you start

  • Run it in an interactive Claude Code session and approve writes to .claude/ (headless claude -p blocks them)
  • Fill safe_commands (we used npm test, npm run lint, npm run typecheck, git status, git diff)
  • Review CLAUDE.md for rules copied from your personal ~/.claude/CLAUDE.md

Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))

Input

bakehouse-api (Express 5 + TypeScript, CI workflow, generated types, a dangerous prod reset script, one failing test). Claude Code headless, twice (run 2 also allowed Write/Edit on ./.claude/**); Codex workspace-write.

Result

Codex: created CLAUDE.md, .claude/commands/test-file.md, check.md, review.md and a valid .claude/settings.json (allow tests/lint/typecheck/status/diff; ask for installs, git writes, db commands, the reset script). Claude Code: "I created `CLAUDE.md`, but the three slash commands and `.claude/settings.json` weren't written: permission to write in `.claude/` wasn't granted".

Claude Code FAILED here. Headless Claude Code refused every write under .claude/ in both runs, even with Write(./.claude/**) allowed, so steps 3-4 only produced drafts. Its CLAUDE.md copied the tester's personal rule ('Never commit, push or deploy without an explicit "commit to GitHub"', naming the tester in run 2) into the shared project file, and run 1 listed `npm run generate:types` under verified commands although it can't run (missing openapi-typescript). It did run the tests, report the failing test and name good risks (client-set prices, off-by-one discount, prod reset script). Codex's files were accurate (it flagged generate:types as unavailable); its CLAUDE.md includes a note that route tests were blocked by its sandbox. Codex also ran `claude doctor` and did a web search on Claude Code permission syntax on its own. After this test the prompt says not to copy personal or global rules into the project file (Claude Code did), to print files it can't write, and to show settings.json rather than write it.

How to check it worked

  • Run every command in CLAUDE.md
  • Check CLAUDE.md for rules from your personal config
  • Open .claude/settings.json in /permissions and try one allowed and one ask command

Common problems

  • claude -p (headless) can't write .claude/ files
  • Personal ~/.claude/CLAUDE.md rules copied into the project file
  • Commands listed as verified that were never run

Try it here

Fill in {{safe_commands}} above first for a better answer, or run it as is and the AI will assume sensible values.

or open in ChatGPT · Claude · Perplexity

How to use this prompt

  1. Fill in the blank above. The more specific you are, the better the answer.
  2. Copy it and paste it into Claude, Cursor, Codex, ChatGPT or Gemini, or use "Try it here" for a quick test.
  3. Read the answer critically: check anything it claims about your code or data before you rely on it.
  • {{safe_commands}} Safe commands

More from c/agents

See all of c/agents →
0 comments

Log in to join the discussion.