https://github.com/jakepeg/icp-rust-vibe-boilerplate
https://github.com/jakepeg/icp-rust-vibe-boilerplate
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jakepeg/icp-rust-vibe-boilerplate
- Owner: jakepeg
- Created: 2025-05-13T21:23:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-14T09:06:42.000Z (about 1 year ago)
- Last Synced: 2025-06-17T23:38:16.775Z (about 1 year ago)
- Language: TypeScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# π§ͺπ₯ IC Vibe Coding Bootcamp - Rust Edition
Welcome to the **IC Vibe Coding Bootcamp (Rust Edition)**! This repository provides a high-quality, production-style template to help you kickstart Internet Computer (ICP) backend development using **Rust**, with best practices in testing, CI/CD, and developer experience.
Whether you're building your first ICP project or want a fast way to set up a maintainable Rust canister architecture, this template is your launchpad. π
---
## π Table of Contents
- [β¨ Features](#-features)
- [π Getting Started](#-getting-started)
- [π Project Structure](#-project-structure)
- [β
Testing Patterns](#-testing-patterns)
- [π CI/CD Workflow](#-cicd-workflow)
- [π§ GitHub Copilot Integration](#-github-copilot-integration)
- [π Resources & Documentation](#-learning-resources)
- [π© Submit Your Project!](#-submit-your-project)
---
## β¨ Features
- π¦ **Rust-based Canister Template**
- π§ͺ **Test Suite**: Powered by Vitest + PocketIC for realistic canister simulation
- π **CI/CD**: GitHub Actions to automate builds, tests, and code quality checks
- π¦ **DFX Config**: Pre-configured with best practices for Rust
- π€ **Copilot Integration**: Automatically generate structured tests & changelogs
---
## π Getting Started
### π§βπ» 1. Get Codespace Ready
A **devcontainer** is preconfigured for you to start coding instantly!
- Click on "Use this Template" β "Create a new repository".
- Click "Code β Open with Codespaces"
- Once the codespace is created, you can open it in VS Code Local
- Everything is pre-installed and ready for you to run the following commands
### 2. Install Dependencies
```bash
npm install
```
### 3. Start Local Blockchain Environment
```bash
dfx start
```
Keep this tab open for reading logs.
### 4. Deploy Locally
Open a new tab, then:
```bash
dfx deploy
```
### 5. Run Tests
```bash
npm test
```
You can also run:
```bash
npm test tests/src/vibe_coding_template_backend.test.ts # individual test
```
---
## π Project Structure
```
ICP-Bootcamp-Vibe-Coding/
βββ src/
β βββ vibe_coding_template_backend/ # Rust backend canister
β β βββ src/ # Rust source files
β β βββ Cargo.toml # Rust dependencies
β βββ declarations/ # Auto-generated canister interfaces
βββ tests/
β βββ src/ # Test files
β βββ global-setup.ts # PocketIC instance
β βββ vitest.config.ts # Vitest configuration
βββ scripts/
β βββ dev-container-setup.sh # Extra set up steps for codespace
β βββ generate-candid.sh # Useful one way script to build, generate candid and did files
βββ dfx.json # ICP config
βββ Cargo.toml # Root Rust workspace config
βββ .github/instructions/ # Copilot general and language specific instructions
βββ .github/prompts/ # Copilot Prompts, like add feature and changes review
βββ .github/workflows/ # GitHub CI/CD pipelines
βββ .devcontainer/devcontainer.json # Container config for running your own codespace
βββ CHANGELOG.md
```
---
## π CI/CD Workflow
Located under `.github/workflows/`, this includes:
- π§ͺ Automated end-2-end test runs
It could be extended to:
- check for security updates (audit);
- test coverage;
- code quality.
---
## π§ **GitHub Copilot Integration**
This project leverages two key customization folders:
- `.github/instructions/` β Provides essential context to guide AI responses.
- `.github/prompts/` β Defines workflow prompts to effectively assist you.
Think of the AI as a super-fast junior developer, handling the heavy lifting while you focus on quality control. Instead of using PRs, youβre reviewing and refining code directly in the IDE through Copilot chat.
### π **About Instructions**
Instructions provide "context" that applies to specific files using regex patterns defined in `applyTo`. They are ideal for project-wide or language-specific guidance.
**Current Instructions:**
- **general:** `applyTo: **`
- **rust:** `applyTo: */*.rs`
- **test:** `applyTo: tests/**`
**Examples of Context You Can Define:**
- This is an ICP project using Rust canisters.
- For Rust, we follow Clippy and Rust FMT style guides and linting tools.
- For tests, we use **Pocket IC** and maintain a specific test structure.
### π οΈ **About Prompts**
Prompts define specific tasks and guide the AI through a structured workflow. They are especially useful for maintaining a consistent development process.
---
#### β¨ **Add Feature Prompt**
```markdown
/add-feature Add a function to decrease the counter value
```
In this workflow, Copilot follows a Spec Driven Workflow:
1. Clarification Phase:
β’ Updates the changelog and asks for any necessary clarifications.
2. Test First Approach:
β’ Generates a test case and ensures it fails, confirming that the test is effectively targeting the desired behavior.
3. Human Confirmation:
β’ The AI pauses for a human to review and confirm the spec, ensuring alignment before proceeding.
4. Implementation Phase:
β’ Implements the code, self-checks for errors, installs necessary libraries, lints, formats, and runs tests to confirm they pass.
**β
Key Takeaways**
When you explore the prompt, please notice:
- CRITICAL PAUSE POINTS
- Strategic pauses allow the human to verify the work in small, reviewable chunks and redirect if necessary.
- Command Explanations
- The prompt can include specific commands or scripts, guiding the AI in self-checking, running scripts, or managing dependencies.
- Task-Specific Advice
- The prompt is the place to add any specific guidance or notes relevant only to the particular task at hand.
#### π§ **Changes Review Prompt**
To run a review, simply call the prompt:
```markdown
/changes-review
```
The AI will analyze the current git diffs, then reference other files in the repo for context. It will generate a comprehensive report for you to review before committing.
#### β
**Focus Areas**
1. **Business Logic:**
- Detects potential unwanted side effects or missing edge cases.
2. **Code Quality:**
- Suggests improvements or refactor opportunities.
3. **Security & Performance:**
- Identifies vulnerabilities or inefficiencies.
#### π **Why It Matters**
- AI can handle the heavy lifting, but it's **your responsibility as the Senior** to validate the findings.
- Double-check and ensure quality β small issues now can become big problems later. π
---
## π Learning Resources
- [Instruction and Prompt Files](https://code.visualstudio.com/docs/copilot/copilot-customization)
- [Agent Mode](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode)
- [Copilot Reference](https://code.visualstudio.com/docs/copilot/reference/copilot-vscode-features)
- [ICP Dev Docs](https://internetcomputer.org/docs)
- [Rust CDK](https://internetcomputer.org/docs/current/developer-docs/backend/rust/)
- [PicJS Doc](https://dfinity.github.io/pic-js/)
- [Vitest Testing Framework](https://vitest.dev/)
---
### π€ **Contributing**
We welcome contributions! If you encounter a bug, have a feature request, or want to suggest improvements, please open an issue or submit a Pull Request.
We especially welcome candidates of limits you face, consider using the **Limit Candidate Form Issue** β it helps us prioritize and address the most impactful limits effectively.
---
## π© Submit Your Project!
π― **Completed your challenge? Submit your project here:**
π’ [Submission Form](https://forms.gle/Sgmm1y2bLXYY7mwC6)
π **Want to explore more challenges? Return to the index:**
π [IC Vibe Coding Bootcamp Index](https://github.com/pt-icp-hub/IC-Vibe-Coding-Bootcamp-Index)
---
**Now go build something fast, tested, and production-ready ππ¦**