Connect GitHub and Set Guardrails for Your AI Coding Tool
How to link GitHub to a full-platform AI builder versus a CLI coding agent, plus a starter system-preferences and guardrails file for each major model — Claude, GPT/Codex, Gemini, Cursor, Copilot, and DeepSeek.
The article text carries the review date. The rate table below is rebuilt from the live catalogue on every deploy.
Thanks
Thanks to Wroxy for their help drafting these tutorials.
This guide is a companion to the outcome-based tutorials (building a website, web app, web game, or mobile game with AI). It covers two things those tutorials assume you already know: how GitHub fits into whichever AI coding tool you pick, and how to give that tool a starter set of rules so it doesn't make expensive or risky decisions on its own.
Full Platforms vs. CLI Agents — What's the Difference
AI coding tools split into two shapes, and the cost and GitHub setup differ for each.
- Full platforms (Replit, Bolt, Lovable, v0) run in the browser, host your project themselves, and typically own the whole loop: editor, database, deploy, and often their own git hosting layer that syncs to GitHub rather than working directly against your local clone. Replit Core is $20/month.
- CLI agents (Claude Code, Cursor CLI/agent mode, OpenAI Codex CLI, Gemini CLI) run in your terminal against a real local git repository. They read and write files directly, and every change is a normal
gitcommit you push yourself — there is no separate hosted sync layer to configure. Claude Code is included in Claude Pro ($20) and Claude Max (from $100), or billed per token on the API (Claude Sonnet 5 at $2 / $10 per 1M, Opus 5 at $5 / $25).
For a quick prototype you do not yet care about owning long-term, a full platform is faster to start. Once you need code review, branch protection or CI on a real repo, a CLI agent working against your actual GitHub repo is usually the cheaper and more controllable choice — you are not paying platform mark-up on top of the underlying model.
One cost rule applies to both: an agent is a tool-call loop, and every file read, test run and retry re-sends the context. Give each task a budget — a maximum number of steps or a dollar cap — and keep the repository context it loads small. Prompt caching (cached input at roughly 10% of list on OpenAI and Anthropic) is what makes long sessions affordable.
Connecting GitHub on a Full Platform
Full platforms connect to GitHub through an account-level integration, not a local git config:
- Replit: Account Settings → Connected Services → GitHub, authorize the Replit GitHub App, then use "Connect to GitHub" inside a given Repl to link it to a new or existing repo. Replit pushes commits on your behalf when you use its version control panel.
- Bolt / Lovable / v0: each has a "GitHub" or "Export to GitHub" button in the project header. The first use triggers a GitHub OAuth prompt scoped to repo creation; approve it once per account, then every project gets a "Push to GitHub" action.
- In all three, only grant the integration access to the specific repositories it needs (GitHub's "Only select repositories" option during the OAuth/App install) rather than blanket access to your whole account.
Connecting GitHub on a CLI Agent
CLI agents don't need a special integration — they use the same git and GitHub auth you'd use manually:
- Install the GitHub CLI (
gh) and rungh auth loginonce, or configure a personal access token / SSH key the normal git way. - Clone the repo (
git clone <url>) and run the agent (claude,codex,cursor-agent,gemini) inside that directory — it now sees real git history and can commit, branch, and open PRs using your existing credentials. - Most of these CLIs (Claude Code included) can call
ghdirectly to open pull requests, meaning GitHub access is really just "isghauthenticated in this shell," not a separate setup step per tool. - Keep the agent's push scope narrow: work on a feature branch, not
main, and require a human-reviewed PR before merge — the same rule you'd apply to a new human contributor.
Starter System Preferences and Guardrails, by Model
Before turning an agent loose on a real repo, give it a short rules file. Every major tool reads one automatically if it's named and placed correctly. Treat this as a floor, not a full policy — add project-specific rules on top.
- Claude (Claude Code):
CLAUDE.mdat the repo root. Loaded automatically at session start. Starter guardrails: state the branch to develop on and never commit directly to main/production; require tests to pass before a change is considered done; name any command that costs money (deploys, paid API calls) and require explicit confirmation before running it; list directories the agent should not modify without asking (secrets, CI config, billing code). - OpenAI (GPT / Codex CLI):
AGENTS.mdat the repo root, plus an optional system-level preference file the CLI reads on startup. Starter guardrails: same branch and test-before-done rules as above; explicitly disallow installing new dependencies without listing them in the PR description; cap how many files a single change may touch before it must be split. - Google (Gemini CLI):
GEMINI.mdat the repo root. Starter guardrails: require a plan/summary before multi-file edits; forbid deleting files without listing them first; require citing which files were read before claiming a bug is fixed. - Cursor:
.cursor/rules/*.mdc(or a single.cursorrulesfile in older setups). Starter guardrails: restrict auto-run/auto-apply mode to non-destructive commands; require manual approval for anything touchingpackage.json, infra config, or environment variables; keep one rule per concern rather than one giant file. - GitHub Copilot:
.github/copilot-instructions.md. Starter guardrails: describe the project's coding conventions and testing commands so suggestions match house style; explicitly note any deprecated patterns Copilot should never suggest, since Copilot has no separate "ask before running" gate the way agentic CLIs do. - DeepSeek: DeepSeek's coding tools (DeepSeek Coder via its CLI, IDE plugins, or the API) don't yet have one universal auto-loaded rules filename the way Claude Code or Gemini CLI do. The reliable approach is to pass your guardrails as the system message/prompt in whatever wrapper you're using it through (its CLI's config file, a Cursor/Continue.dev integration pointed at the DeepSeek API, or your own script) — mirror the same content as the
CLAUDE.mdstarter above: branch rules, test-before-done, and a list of commands that require confirmation.
Whatever the filename, keep every guardrails file to the same core three rules to start: never push to a protected branch directly, never run a paid or destructive command without confirmation, and always run existing tests before declaring a task complete. Add tool- or project-specific rules after those three are in place, not before.
Key Takeaways
- →Full platforms (Replit, Bolt, Lovable, v0) connect to GitHub via an account-level OAuth integration; CLI agents just use your existing git/gh authentication
- →Scope any GitHub integration to specific repositories, and have agents work on a feature branch with a human-reviewed PR before merge
- →Claude Code reads CLAUDE.md, GPT/Codex reads AGENTS.md, Gemini CLI reads GEMINI.md, Cursor reads .cursor/rules, Copilot reads .github/copilot-instructions.md — DeepSeek tools take the same rules as a system prompt
- →Every guardrails file starts with three rules: no direct pushes to protected branches, confirm before paid or destructive commands, run tests before declaring done
- →Agents are tool-call loops that re-send context every step — give each task a step or dollar budget; Claude Code is included in Claude Pro ($20) and Max (from $100)
Editorial context
Who is this for?
Developers, startups, and teams who want to reduce their AI API or subscription costs without sacrificing quality.
When NOT to use this
Users who need real-time data, image generation, or proprietary enterprise integrations may need more specialised tools.
Pricing insights
AI pricing varies widely — some models charge per token while others use flat subscriptions. Token-based APIs are usually cheaper for moderate usage, while subscriptions suit power users with high and consistent volume.
Alternatives to consider
Consider DeepSeek V4 Flash for cost-effective coding and writing, Gemini 3.8 Flash for fast tasks, or Claude Haiku 4.5 for lightweight structured work. Use the calculator to compare your specific usage.
Final verdict
The cheapest AI tool is the one that fits your exact workload. Use the cost calculator and decision engine on this site to find your optimal stack — most users can cut AI spend by 50% or more.
Frequently Asked Questions
Which file does each AI coding tool read for rules?
Claude Code reads CLAUDE.md, OpenAI Codex reads AGENTS.md, Gemini CLI reads GEMINI.md, Cursor reads .cursor/rules, and GitHub Copilot reads .github/copilot-instructions.md — each at the repo root. DeepSeek tools take the same rules as a system prompt.
Do CLI agents need a special GitHub integration?
No. They use your existing git and gh authentication. Run gh auth login once, clone the repo, and the agent can branch, commit and open PRs with your credentials.
How do I stop a coding agent from running up a bill?
Put three rules in its guardrails file — no direct pushes to protected branches, confirm before paid or destructive commands, run tests before declaring done — and give each task a step or dollar budget. Claude Code inside Claude Pro ($20) or Max (from $100) caps exposure to the plan.
Related
Free courses · no sign-up
Still deciding? Learn the basics first, then come back to the prices.