Bỏ qua để đến nội dung

Sử dụng cơ bản

Hướng dẫn này giới thiệu các tính năng cơ bản và cách sử dụng Galaxy CLI hiệu quả.

Khi khởi động, Galaxy hiển thị ASCII art banner:

____ _ ____ _ ___
/ ___| __ _| | __ ___ ___ _ / ___| | |_ _|
| | _ / _` | |/ _` \ \/ / | | || | | | | |
| |_| | (_| | | (_| |> <| |_| || |___| |___ | |
\____|\__,_|_|\__,_/_/\_\\__, | \____|_____|___|
|___/
Version: 2.0.0
ENTER to send • \ + ENTER for new line • @ to mention files
Current folder: /path/to/project
Agent=auto Git=OFF Test=OFF Review=OFF
> _
Terminal window
> _ # Cursor chờ input

Bạn có thể:

  • Nhập natural language requests
  • Sử dụng internal commands (bắt đầu với /)
  • Dùng keyboard shortcuts

Galaxy có thể trả lời câu hỏi về programming:

Terminal window
> React hooks là gì?
Terminal window
> So sánh Next.js App Router và Pages Router
Terminal window
> Cách optimize performance cho React app?

Yêu cầu Galaxy phân tích cấu trúc và tech stack:

Terminal window
> Phân tích dự án này

Galaxy sẽ:

  1. Scan file structure (file_tree)
  2. Đọc package.json, README.md
  3. Analyze tech stack
  4. List features hiện có
  5. Suggest improvements

Example Output:

📊 Phân tích dự án: My Next.js App
🏗️ Tech Stack:
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS
- Prisma + PostgreSQL
✨ Features:
1. User Authentication
2. Blog Posts (CRUD)
3. Comment System
📁 Cấu trúc:
- app/ - Next.js pages
- components/ - React components
- lib/ - Utilities
- prisma/ - Database schema
💡 Đề xuất:
1. Add API documentation
2. Implement caching layer
3. Add E2E tests
4. Setup CI/CD
  1. Mô tả dự án muốn tạo

    Terminal window
    > Tạo app todo list với React và TypeScript
  2. Galaxy phân tích và đề xuất

    BA Agent sẽ phân tích requirements

  3. Xác nhận plan

    Terminal window
    > yes, làm đi
  4. Galaxy tự động implement

    Từng step sẽ được execute với progress tracking

Xem chi tiết →

Thêm feature mới vào dự án hiện có:

Terminal window
> Thêm search functionality với debouncing
Terminal window
> Implement real-time notifications với WebSocket

Xem chi tiết →

Yêu cầu Galaxy refactor code:

Terminal window
> Refactor components folder để dễ maintain hơn
Terminal window
> Extract reusable hooks từ component này
Terminal window
> Tại sao component này re-render nhiều lần?
Terminal window
> Làm sao fix lỗi "hydration mismatch" trong Next.js?

Để nhập nhiều dòng, dùng \ + Enter:

Terminal window
> Tạo app với features sau: \
- User authentication \
- Post CRUD \
- Comment system

Dùng / để duyệt lịch sử input:

Terminal window
> /history # Xem 10 input gần nhất
Recent inputs:
1. Tạo app Next.js
2. Thêm authentication
3. Phân tích dự án

Khi gõ /, Galaxy hiển thị suggestions:

Terminal window
> /h
┌─────────────────────────────────────┐
/help Hiển thị lệnh
/history Xem lịch sử
└─────────────────────────────────────┘

Dùng Tab hoặc để chọn, Enter để execute.

Galaxy hiển thị progress khi đang làm việc:

⠋ Thinking...
⚡ EXECUTE (npm install react)
↳ ✓ Success. Output: 12 lines.
📝 APPLY PATCH (src/App.tsx)
↳ Succeeded. File edited. (+15 added, -3 removed)
📋 Implementation Plan:
☐ Step 1: Initialize project
☒ Step 2: Install dependencies - Completed
⚙ Step 3: Implement Feature A - In progress...
☐ Step 4: Implement Feature B

Galaxy làm việc trong current working directory:

Terminal window
> /pwd
Working directory: /Users/you/projects/my-app

Để đổi directory, thoát Galaxy và cd:

Terminal window
> /exit
$ cd ../another-project
$ bun run start
Terminal window
bun run start
Terminal window
> /clear
Cleared conversation and progress
Terminal window
> /exit
Goodbye!

Hoặc Ctrl+C.

Galaxy lưu progress vào file .galaxy/progress.json:

{
"projectName": "My App",
"createdAt": "2025-01-10T10:00:00Z",
"steps": [
{
"step": 1,
"action": "Initialize project",
"status": "completed"
},
{
"step": 2,
"action": "Implement Feature A",
"status": "in-progress"
}
]
}

Xem progress location:

Terminal window
> /progress
📄 Progress file: /path/to/project/.galaxy/progress.json

Mô tả chi tiết

Càng chi tiết càng tốt khi describe requirements:

Terminal window
# ❌ Vague
> Tạo app blog
# ✅ Detailed
> Tạo blog app với Next.js 14,
Markdown posts, tag system,
search, RSS feed

Confirm before execute

Luôn review plan trước khi confirm:

Terminal window
# Review plan
📋 Implementation Plan:
Step 1: ...
Step 2: ...
# Adjust if needed
> Thêm step test vào plan
# Then confirm
> yes

Incremental work

Làm từng phần thay vì all-at-once:

Terminal window
# Session 1
> Tạo basic structure
# Session 2
> Thêm authentication
# Session 3
> Thêm admin panel

Review generated code

Luôn review code được generate:

Terminal window
git diff
# Review changes
npm run dev
# Test functionality
Terminal window
# Commit trước khi Galaxy làm việc
git add .
git commit -m "Before Galaxy changes"
# Chạy Galaxy
> Thêm feature X
# Review changes
git diff
# Commit hoặc rollback
git commit -m "Added feature X"
# or
git reset --hard HEAD
Terminal window
# Backup trước
cp -r . ../backup
# Chạy Galaxy
> Refactor codebase này
# Test thoroughly
npm test
npm run build

Dùng Galaxy để học:

Terminal window
> Giải thích code này và cách improve nó
> [paste code]
> Viết lại component này theo best practices
PhímChức năng
EnterSend message
\ + EnterNew line
/ Browse history
TabNext suggestion
Shift+TabPrevious suggestion
EscClose suggestions
Ctrl+CExit Galaxy
Terminal window
# Check Ollama running
ollama list
# Check Gemini API key
echo $GEMINI_API_KEY
Terminal window
# Check terminal output
# Galaxy hiển thị error details
# Try again hoặc skip step
> skip step này, làm tiếp
Terminal window
# Clear và restart
> /clear
> Bắt đầu lại từ đầu