Chapter 9. Safety and Responsibility — Secrets, Publishing, and Licenses
Required Read this to follow this stage.In One Line: Never upload secrets like passwords or API keys to a repository. Once you commit a secret, it stays in the Git history even after you delete the file. If a secret leaks, your very first step is to change that secret (revoke and rotate it)—not to erase the history.
This chapter is based on the official GitHub and Claude Code docs and the Anthropic Consumer Terms of Service, checked on November 1, 2026. For safety rules that apply to any AI, see Stage 1, Chapter 9. This chapter covers the new risks that come with public repositories and deployment. This is not legal advice. Please check with a professional for important decisions.
Never Upload Secrets
A secret is a credential that gives access to sensitive systems and data. Examples include API keys and tokens for external services, or database passwords.[1] GitHub tells you to never upload sensitive information like passwords or API keys to a repository.[2]
Why is the warning so strong? A committed secret becomes part of your Git history. Even if you delete it from the latest file, it stays in the history.[3] What is more, secrets in public repositories get picked up by search engines and specialized scanning services.[4]
Here are common ways secrets leak:[5]
- Accidentally committing a value you put in while testing
- Configuration files like
.env - Writing a real key in an example inside documentation or a README
Quick check
You committed a secret value, then deleted that file in the next commit. What happens?
Three Layers of Protection
| Step | What to do | Basis |
|---|---|---|
| 1. Keep it out | List it in .gitignore and block Claude from reading it | Chapter 2, this section |
| 2. Get blocked | GitHub push protection blocks it before upload | This section |
| 3. Replace it | Revoke and rotate immediately if it leaks | This section |
Source: Summary by this guide (see footnotes for basis)
1. Keep it out. There are three things to do. Do them in order, from the top.
- Add it to
.gitignorefirst: Put any file containing secrets into.gitignore(the list of files Git ignores) from the very start (Chapter 2). The order matters. If you already committed a file, simply adding it to the list will not make Git ignore it. - Stop Claude from reading it: Add a
Readdeny rule to Claude Code's permission rules (settings that decide what Claude is allowed to do). For example, if you writeRead(./.env), Claude's file tools cannot read.env.[6] If it is hard to write it yourself, try asking Claude: "Add aRead(./.env)deny rule to the permission rules so you can't read.env." We covered permissions in Claude Code, Chapter 4. - Keep it outside the repository: Even deny rules are not perfect. They do not block commands that read files without naming them, or other programs that open files on their own.[7] So the safest approach is to keep secret files outside your repository folder altogether.
Even when an automated workflow (GitHub Actions, Chapter 5) needs a secret, do not write it in a repository file. Instead, store it in GitHub Secrets (a place in the repository settings where you keep secrets separately).[8][9] The to-do board does not need any secrets, so for now just know that this place exists.
2. Get blocked. GitHub's push protection blocks pushes containing secrets before they reach your repository.[10] On your account, protection that stops you from pushing secrets to public repositories is turned on by default.[10:1] Still, treat this as a last safety net. It is not guaranteed to catch every kind of secret, so always follow Step 1 first.
3. Replace it. If you get an alert that a secret has leaked, rotate that credential immediately.[11] Rewriting Git history requires coordination with anyone sharing the repository and has side effects. The official docs also say that if the data you need to remove is a secret, your first step is to revoke and rotate it.[12]
Quick check
According to official docs, what is the very first step if a secret leaks into a public repository?
What Comes with Going Public
Anyone can view a public repository and a Pages site (Chapters 2 and 7). Check these items before you make your work public:
- Personal information: Do not include notes with real names, contact details, or addresses. That is why you do not upload your Stage 3 organizer notes as-is.
- Visitor information: Pages logs visitor IP addresses for security purposes (Chapter 7).
- Responsibility for approval: You are responsible for reviewing proposed code and commands for safety before you approve them.[13]
Quick check
Why shouldn't you upload your raw notes from the Step 3 organizer tool directly to a public repository?
Licenses and AI-Generated Work
If you do not choose a license, default copyright laws apply. That means other people cannot copy, distribute, or modify your code (Chapter 2). If you want to let others use your work, pick a license.
As for rights to AI-generated code, this guide did not find an official legal answer. The terms for personal Claude accounts only say that the company passes its rights to you "if any."[14] They do not answer whether AI-generated code gets copyright protection. If you are using it for something important, check with a professional.
More details: The terms clause we checked (click to expand)
What we did verify is this clause in the Anthropic Consumer Terms of Service, which applies to personal Claude accounts (Codex and Antigravity follow their own companies' terms). Provided you follow the terms, Anthropic assigns to you all of its rights—"if any"—in the Outputs.[14:1] This does not answer whether AI-generated code gets copyright protection in the first place.
Also check whether your data is used for training. The official docs state that on Claude Free, Pro, Max, and Ultra accounts, when the training setting is turned on, your work in Claude Code is also used to train new models.[15] Where to check this setting is in Chapter 9 of the Stage 2 Claude guide. If you chose the ChatGPT guide in Stage 2, you only need to read this one chapter of the Claude guide, Chapter 9 "Privacy and Safety."
Quick check
What happens if you do not choose a license for your repository?
Watch the Parts Made by Others
Software often relies on parts (packages) brought in from many places. Security flaws can slip in through those parts without you knowing.[16]
If your page barely uses outside parts—like our to-do board—you have less to worry about. There is just one thing to remember. If Claude asks to install a new part, ask what it is installing and why before you approve it (the same question you ask when checking a plan in Chapter 4).
More details: When you use more parts (click to expand)
GitHub's Dependabot warns you if a part you use has a known vulnerability (security flaw).
Quick check
What does this guide recommend when Claude asks to install a new part (package)?
Try It Yourself — Pre-Publish Checklist
- Check if your to-do board folder has a
.gitignorefile and whether it lists files that might hold secrets (such as.env). If not, ask Claude to create one for you. - Ask Claude: "Check if there are any strings in this repository that look like passwords, API keys, or tokens. If you find any, just tell me the file and line number—don't show me the value."
- Skim through
README,SPEC.md, and your data yourself to make sure there are no real names or contact details. - Think about whether to choose a license. Remember that if you do not choose one, others cannot use your code.
- If you did upload a secret: first revoke and replace that value where it was issued, and clean up the repository after that.
Up next: In Chapter 10, you will do a hands-on project that puts Chapters 1 through 9 together from start to finish.
Summary
- Never upload secrets. Once committed, they stay in the Git history even if deleted, and public repositories get scanned.
- Three layers: keep secrets out with
.gitignore(aReaddeny rule only blocks Claude's file tools), let push protection block them, and rotate them first if they leak. - Do not put personal information in public repositories or Pages. You are responsible for reviewing code and commands before approving them.
- Without a license, others cannot use your code. We found no official answer on copyright for AI outputs.
- Before approving a new package installation, ask what it is and why it is needed.
Glossary
| Term | One-line meaning |
|---|---|
| Secret | A credential like a password or API key |
| Push protection | A GitHub feature that blocks pushes containing secrets in advance |
| Rotate | Replacing a leaked secret with a new value |
| Dependency | An outside software part that your software relies on |
Finished this chapter?
Progress is saved only in this browser. See your progress on the full table of contents.
Next chapter: Chapter 10. Hands-On Project
References (16)
GitHub official docs, "Secret leakage risks". "Secrets are credentials that grant access to sensitive systems and data." / "API keys and tokens used to authenticate with external services" docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Adding locally hosted code to GitHub". "Never
git add,commit, orpushsensitive information, for example passwords or API keys, to a remote repository." docs.github.com (checked on 2026-11-01) ↩︎GitHub official docs, "Secret leakage risks". "These hardcoded secrets become part of your Git history and remain accessible even after being removed from the latest commit." docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Secret leakage risks". "Public repositories with exposed secrets are indexed by search engines and specialized scanning services." docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Secret leakage risks". "Secrets in configuration files such as
.envfiles or infrastructure-as-code templates" docs.github.com (checked on 2026-11-01) ↩︎Claude Code official docs, "Configure permissions". "To block Claude's file tools from reading a file or directory, add a
Readdeny rule for its path, such asRead(./.env)orRead(./secrets/**);" code.claude.com (checked on 2026-11-01) ↩︎Claude Code official docs, "Configure permissions". "They don't apply to a command that reads files without naming them, such as
grep -r pattern .run from the directory that holds the file, or to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself." code.claude.com (checked on 2026-11-01) ↩︎Claude Code official docs, "Claude Code GitHub Actions". "Never commit API keys or OAuth tokens directly to your repository." code.claude.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Secrets". "GitHub Actions can only read a secret if you explicitly include the secret in a workflow." docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Push protection". "Rather than alerting you to credential leaks after the fact, push protection blocks pushes that contain secrets before they reach your repository." / "Stops you from pushing secrets to public repositories on GitHub" docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Secret scanning". "When you receive an alert, rotate the affected credential immediately to prevent unauthorized access." docs.github.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Removing sensitive data from a repository". "It is important to note that if the sensitive data you need to remove is a secret (e.g. password/token/credential), as is often the case, then as a first step you need to revoke and/or rotate that secret." docs.github.com (checked on 2026-11-01) ↩︎
Claude Code official docs, "Security". "You're responsible for reviewing proposed code and commands for safety before approval." code.claude.com (checked on 2026-11-01) ↩︎
Anthropic Consumer Terms of Service. "Subject to your compliance with our Terms, we assign to you all of our right, title, and interest—if any—in Outputs." anthropic.com (checked on 2026-11-01) ↩︎
Claude Code official docs, "Data usage". "We will train new models using data from Free, Pro, Max, and Ultra accounts when this setting is on (including when you use Claude Code from these accounts)." code.claude.com (checked on 2026-11-01) ↩︎
GitHub official docs, "Dependabot alerts". "Software often relies on packages from various sources, creating dependency relationships that can unknowingly introduce security vulnerabilities." docs.github.com (checked on 2026-11-01) ↩︎