Spaces:
Running
A newer version of the Gradio SDK is available: 6.19.0
title: SoniCoder
emoji: π
colorFrom: purple
colorTo: green
sdk: gradio
sdk_version: 6.14.0
python_version: '3.11'
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_scopes:
- read-repos
- write-repos
- manage-repos
SoniCoder
An AI-powered autonomous coding agent running entirely locally with no external API dependencies. Powered by MiniCPM5-1B (2.17 GB).
Inspired by Claude Code, SoniCoder adds:
- π€ Agent Loop β model calls tools (read/write/edit/glob/grep/bash/todos) in a feedback loop
- π― Skills System β load markdown skill files at runtime (frontend-design, feature-dev, code-review, debugging, fullstack-scaffold, commit-workflow)
- β‘ Slash Commands β
/commit,/review,/feature,/design,/explain,/test,/refactor,/skill,/agent,/github,/help - π§ Custom Agents β describe a specialized agent in natural language and the AI generates a full persona (system prompt + tool whitelist + auto-loaded skills + temperature + max iterations). Activate via
/agent use <name>or the Agents panel. Built-ins:code-reviewer,test-writer. - π₯ GitHub Import β paste any GitHub URL (or use
/github <url>) to shallow-clone a repo into the workspace. Heavy dirs (.git,node_modules,__pycache__,.venv,dist) are stripped automatically. Supportsbranch,subdir, andtarget_subdiroptions. - π¦ GitHub Push β push the current workspace to any GitHub repo with just 3 inputs: repo name, GitHub API token, and username. Uses
--force-with-leaseso the workspace is the source of truth. Available in the Deploy tab. - πͺ Hooks System β pre/post tool execution rules (block dangerous commands, warn on debug code/secrets)
- π Sandboxed Workspace β agent manipulates files in
./workspace/(path-escape protected) - β Todo Lists β track multi-step tasks Claude Code-style
- π HuggingFace Deploy β push generated projects directly to HuggingFace Spaces
Features (original)
- Local Inference: MiniCPM5-1B via
transformersβ no API keys - Multi-Language: Python, JavaScript, TypeScript, Java, Go, Rust, PHP, Ruby, C#, Swift, Kotlin
- Frameworks: React, Vue, Next.js, Express, Flask, Django, FastAPI, Spring Boot, and more
- Live Preview: sandboxed iframe preview of generated web apps
- Code Execution: run generated Python and see output
- Project Download: ZIP the generated project
- HuggingFace Deploy: one-click push to HF Spaces (Static/Gradio/Streamlit/Docker)
Supported Languages & Frameworks
| Language | Frameworks |
|---|---|
| Python | Flask, Django, FastAPI, Streamlit, Gradio, Plain Python |
| JavaScript | React, Vue.js, Next.js, Express.js, Node.js, Vanilla JS |
| TypeScript | React, Next.js, Express.js, NestJS |
| HTML/CSS/JS | Tailwind CSS, Bootstrap, Vanilla |
| Java | Spring Boot, Maven, Gradle |
| Go | Gin, Fiber, Echo, Plain Go |
| Rust | Actix, Axum, Rocket |
| PHP | Laravel, Symfony, Plain PHP |
| Ruby | Rails, Sinatra |
| C# | ASP.NET, Blazor |
| Swift | Vapor, SwiftUI |
| Kotlin | Ktor, Spring Boot |
Agent Tools
The agent can call these tools (Claude Code-style):
| Tool | Description |
|---|---|
read_file |
Read a file from the workspace |
write_file |
Write content to a file |
edit_file |
Replace text in a file (with uniqueness check) |
multi_edit |
Apply multiple edits atomically |
list_dir |
List directory contents |
glob |
Find files matching a pattern |
grep |
Search file contents with regex |
bash |
Run a shell command (sandboxed) |
todo_write |
Replace the todo list |
todo_read |
Read the current todo list |
todo_update |
Update a single todo |
Slash Commands
| Command | Description |
|---|---|
/commit [msg] |
Create a git commit with a generated message |
/review [file] |
Review changes for bugs and quality |
/feature <desc> |
Guided feature development |
/design <brief> |
Generate a distinctive frontend design |
/explain <target> |
Explain how code works |
/test [target] |
Generate tests |
/refactor <target> |
Refactor code for clarity |
/skill <name> |
Load and apply a skill |
/agent create <desc> |
AI generates a custom agent from a natural-language description |
/agent use <name> |
Activate a saved agent for subsequent prompts |
/agent list |
List all saved agents |
/agent show <name> |
Display an agent's full definition |
/agent delete <name> |
Delete a user-defined agent |
/agent reset |
Reset to default SoniCoder persona |
/github <url> [subdir] [--branch <name>] [--into <path>] |
Import a GitHub repo into the workspace (shallow clone, heavy dirs stripped) |
/help |
Show available commands and skills |
GitHub Import
SoniCoder can clone any public GitHub repository into the sandboxed workspace so the agent can read, edit, extend, or refactor it. Imported repos are shallow-cloned (depth 1) and stripped of heavy directories (.git, node_modules, __pycache__, .venv, dist, build, etc.) to keep the workspace lean.
Accepted URL formats:
https://github.com/<owner>/<repo>https://github.com/<owner>/<repo>.githttps://github.com/<owner>/<repo>/tree/<branch>β checkout a specific branchhttps://github.com/<owner>/<repo>/tree/<branch>/<subdir>β import only a sub-directorygit@github.com:<owner>/<repo>.gitβ SSH form (rewritten to HTTPS internally)
Two ways to import:
- Via the Agent tab UI: Open the Agent tab, paste the GitHub URL into the "Import Project from GitHub" box at the top, optionally specify
branch,subdir, orinto path, then click β¬ Import. The workspace tree and todo list refresh automatically, and agent mode is enabled if it wasn't already. - Via the
/githubslash command (Agent mode): Type/github https://github.com/owner/repoin chat. The agent runs the import, lists the top-level files, and suggests next steps. Flags:--branch <name>,--into <path>,--depth <N>.
Examples:
/github https://github.com/fastapi/fastapi
/github https://github.com/vercel/next.js examples/with-typescript --into next-ts-demo
/github https://github.com/pallets/flask --branch 2.3.x
API endpoints:
| Endpoint | Description |
|---|---|
import_github(url, branch, subdir, target_subdir, depth, timeout) |
Clone a GitHub repo into the workspace |
github_url_examples() |
Return accepted URL formats and notes |
Security: Only github.com URLs are accepted (HTTPS or SSH form). The clone happens in a temp directory and is then copied into the workspace β the upstream repo is never modified. Path-escape protection on target_subdir prevents writing outside the workspace.
GitHub Push (Update a GitHub repo)
Push the current SoniCoder workspace back to a GitHub repo as a commit. Designed to be minimal β only 3 required inputs:
- Repository name β either
my-app(combined with your username) orusername/my-app. - GitHub API token β a Personal Access Token (PAT) with
reposcope. Create one here. - Username β the GitHub user (or org) that owns the repo and matches the token.
How to use:
- Open the Deploy tab.
- Scroll to the "Push Update to GitHub" section (below the HuggingFace section).
- Fill in the 3 required fields (optionally expand "Advanced" to set
branchorcommit message). - Click π¦ Push to GitHub. A confirmation dialog shows the target repo + branch.
- On success, the status box shows the commit SHA, commit URL, and repo URL.
How it works (under the hood):
- The workspace is snapshotted (via
snapshot_workspace()β same function used for HuggingFace deploy). - A fresh git repo is created in a temp dir; the snapshot files are written in.
git init -b <branch>βgit add -Aβgit commit -m <message>.git push --force-with-lease https://<username>:<token>@github.com/<owner>/<repo>.git <branch>.- If
--force-with-leasefails because the remote has no refs yet (brand-new empty repo), it retries with a plaingit push. - The temp dir is deleted. The token is never logged; error messages scrub it before being returned to the UI.
API endpoint:
| Endpoint | Description |
|---|---|
push_github(repo_name, github_token, username, branch?, commit_message?, timeout?) |
Snapshot workspace β commit β push to GitHub |
Security notes:
- The token is sent over HTTPS to the SoniCoder backend, used once for the push, then dropped (not stored, not logged).
- Error messages are scrubbed to remove the token before being returned to the frontend.
--force-with-leaseis used instead of--forceso the push fails loudly if the remote moved (rather than silently overwriting someone else's commits). For a brand-new empty repo, it falls back to a plain push.- The push happens from a temp dir β your local SoniCoder workspace is never turned into a git repo, and the workspace's
.git(if any) is never read.
Custom Agents
Custom agents are AI-generated personas that layer on top of the base SoniCoder system prompt. Each agent defines:
- A system-prompt extension (persona, workflow, output format)
- A tool whitelist (e.g. a read-only reviewer gets
read_file,grep,bashbut notwrite_file) - Auto-loaded skills (e.g.
code-reviewfor a reviewer agent) - A temperature and max_iterations override
Two ways to create one:
- AI-generated (recommended): Type
/agent create <natural-language description>in chat, or use the "AI-Generate a Custom Agent" box in the Agent tab. The model authors anAGENT.mdfile for you. - Manual: Click "Write manually" in the Agents panel and fill in the fields directly.
Built-in agents:
code-reviewerβ read-only reviewer that produces a structured issues tabletest-writerβ generates pytest/jest tests, runs them, and iterates until green
Agent files are saved to workspace/.sonicoder/agents/<name>/AGENT.md. Built-ins live in code/agents/builtins/ and cannot be deleted.
Built-in Skills
- frontend-design β distinctive visual design guidance (palette, typography, signature)
- feature-dev β 7-phase guided feature implementation
- code-review β high-signal review focusing on bugs and security
- debugging β systematic 6-phase debugging workflow
- fullstack-scaffold β project structure rules for any framework
- commit-workflow β conventional commits best practices
Add custom skills in workspace/.sonicoder/skills/<name>/SKILL.md.
Built-in Hooks
- block-dangerous-rm β blocks
rm -rf /,~,$HOME,.. - warn-debug-code β warns on
console.log,debugger,print,alert - warn-secrets-in-code β warns on hardcoded API_KEY/SECRET/TOKEN/PASSWORD
- warn-eval-exec β warns on
eval()andexec()
Add custom hooks in workspace/.sonicoder/hooks/<name>.local.md.
Local Run
pip install -r requirements.txt
python app.py
The model (MiniCPM5-1B, ~2.17 GB) downloads automatically on first run.
Project Memory
The CLAUDE.md file at the project root is the agent's persistent memory. Edit it freely to override defaults and document project-specific conventions.
HuggingFace Deploy
- Generate your application
- Go to the "Deploy" tab
- Sign in with HuggingFace OAuth (or paste a token)
- Select the Space SDK (Auto, Docker, Static, Gradio, Streamlit)
- Click "Push to HuggingFace"
No External APIs
This application does not use any external API calls. All model inference runs locally using transformers with MiniCPM5-1B. Web search uses DuckDuckGo/Google HTML scraping (no API key).