Mastering Claude Code in the Command Line
- Nishadil
- September 04, 2026
- 0 Comments
- 4 minutes read
- 0 Views
- Save
- Follow Topic
A hands‑on walkthrough for building a FastAPI‑SQLite CRUD API with Claude Code
Learn how to install, configure, and use Claude Code from the terminal to scaffold, test, and run a small FastAPI project backed by SQLite, all with real‑time AI assistance.
Claude Code lets you talk to an AI assistant right inside your terminal. It can peek at your folder, spin up files, fire off commands, and even run a test suite – all while you watch the conversation unfold.
Before you dive in, make sure you have a few things ready: the Claude Code binary (linked to your Anthropic account), Python 3.10 or newer, Git, and a decent shell. If you plan on opening a pull request later, the CLI mode is the way to go.
First things first – sign in. Run /login or simply claude and follow the prompts; the tool will store your token so you don’t have to type it again.
Next, set up a fresh project directory and a virtual environment. Something like:
mkdir books-api && cd books-apipython -m venv .venv && source .venv/bin/activate
Now you’re ready to start Claude. Typing claude from inside books-api launches an interactive session. You can also pass a one‑off query with claude "your question" or continue a previous chat with -c. A few handy flags include --model to pick a different model, --worktree to sandbox changes, and --name to label the session for later reference.
One of the most useful knobs is the permission mode. By default Claude asks before touching a file, but you can let it auto‑approve edits (acceptEdits), run everything silently (bypassPermissions), or stay in a read‑only “plan” mode where it just tells you what it would do. Switch modes on the fly with Shift+Tab, or start a session directly in a given mode, for example:
claude --name books-api --permission-mode plan
In plan mode Claude will explore the repo and sketch a roadmap without actually creating files. That’s perfect for a quick sanity check before committing to changes.
With the session humming, give Claude a concrete task. In this example we asked it to “build a CRUD API for a book collection using FastAPI and SQLite, with SQLAlchemy models, Pydantic schemas, and a pytest suite covering each endpoint – keep it to four files.” Claude responded with a concise plan: it will add database.py, schemas.py, main.py, test_main.py, and a requirements.txt.
After you approve the plan, Claude proceeds to generate the code. The resulting tree looks like this:
books-api/
├─ database.py
├─ schemas.py
├─ main.py
├─ test_main.py
└─ requirements.txt
Some snippets give you a feel for the output. For example, the route to list books reads:
@app.get("/books", response_model=list[schemas.Book])
def list_books(db: Session = Depends(get_db)):
return db.query(models.Book).all()
And the create‑book endpoint:
@app.post("/books", response_model=schemas.Book, status_code=201)
def create_book(book: schemas.BookCreate, db: Session = Depends(get_db)):
record = models.Book(book.model_dump())
db.add(record)
db.commit()
db.refresh(record)
return record
Running the project is just as straightforward. Inside the Claude session you can drop to a shell by prefixing commands with !. Install the deps and fire up the tests:
!pip install -r requirements.txt!pytest -q
If something goes wrong, the test output streams back into the conversation, letting Claude diagnose the issue and suggest fixes.
For longer‑running tasks, like launching the development server, press Ctrl+B to push the process to the background. Then you can keep chatting while the server lives on:
!uvicorn main:app --reload
With the server humming you can fire off a few curl calls right from the same session to see the API in action:
!curl -s -X POST localhost:8000/books -H "Content-Type: application/json" -d '{"title":"Dune","author":"Frank Herbert","published_year":1965,"isbn":"123456"}'!curl -s localhost:8000/books
Before you close the session, take a moment to review what Claude changed. The /diff command shows you the current Git diff, the changes made in each turn, or a file‑by‑file view. This safety net helps you verify everything before you commit.
All in all, Claude Code turns a mundane terminal into a collaborative coding partner. Whether you’re scaffolding a brand‑new microservice or iterating on existing code, the blend of AI insight and direct command‑line control can shave hours off the usual workflow.
- India
- News
- Technology
- Finance
- TechnologyNews
- Jobs
- Banking
- AndroidDevelopment
- Sql
- Cbse
- Python
- WebDevelopment
- Ssc
- GeneralKnowledge
- ClaudeCode
- Javascript
- AiAssistedCoding
- React
- Aptitude
- InterviewExperience
- CompetitiveProgramming
- CodingContests
- TechnicalBlogs
- GateCse
- CommandLineAi
- FastapiTutorial
- SqliteCrud
- PythonVirtualEnvironment
- CliDevelopmentWorkflow
Editorial note: Nishadil may use AI assistance for news drafting and formatting. Readers can report issues from this page, and material corrections are reviewed under our editorial standards.