Module 6 of 6
Maintenance and Optimization
Enhancements, branches, staging, releases, monitoring, backups, security updates and controlling AI, API and hosting costs.
0% · 0 of 9 lessons
Launching is the beginning, not the end. This module covers how to keep improving the application safely, keep it healthy and secure, and keep its costs under control — using the same ChatGPT and Claude Code feedback loop.
Ongoing application enhancement lifecycle
1. Feedback and ideas
Users, logs, metrics2. Plan with ChatGPT
Scope, risks, prompt3. Feature branch
Claude Code implements and tests4. Validate
Local and staging testing5. Merge and deploy
Main → production6. Monitor
Logs, errors, costs, backups
Application enhancements
Treat every enhancement as a mini-project:
- Describe the change to ChatGPT, including the user problem it solves.
- Ask for impact: what existing features, data or users are affected?
- Agree on acceptance criteria and whether a database change is needed.
- Generate one consolidated Claude Code prompt with LOW GAS instructions.
- Implement on a feature branch, test, review and merge.
- Smoke test production after deployment.
Application Enhancement
- Purpose
- Add a new feature to a live application safely, on a feature branch, without breaking existing behavior.
- When to use
- After launch, whenever you add or change functionality. Plan the enhancement with ChatGPT first for anything non-trivial.
[ENHANCEMENT NAME][FEATURE DESCRIPTION AND USER STORY][ACCEPTANCE CRITERIA][DATA OR SCHEMA CHANGES][feature/short-name]# Enhancement — [ENHANCEMENT NAME] ## Operating instructions Use LOW GAS throughout this task. Minimize token consumption, unnecessary analysis, repetitive audits, readiness checks and intermediate reports. Consolidate related implementation activities. Do not create additional planning phases or request approval for routine implementation decisions. Run essential tests, type checking and production builds. Do not compromise security or functionality to reduce model usage. ## Context This application is live in production. Read CLAUDE.md and README.md first. Existing functionality must keep working. ## Feature [FEATURE DESCRIPTION AND USER STORY] ## Acceptance criteria [ACCEPTANCE CRITERIA] ## Data or schema changes [DATA OR SCHEMA CHANGES] ## Requirements - Work on a new branch named [feature/short-name] created from main. - Database changes must use backward-compatible migrations that do not delete existing data. Describe any migration that cannot be reversed. - Add tests for the new behavior and keep existing tests passing. - Add any new environment variables to .env.example with placeholder values and document them. - Update README.md and CLAUDE.md if commands or architecture change. ## Validation Run tests, type checking and the production build. Commit and push the feature branch. Do not merge into main and do not force-push. ## Completion report Features implemented, files changed, migration details, results, branch name, commit hash, manual testing steps and deployment considerations.
Feature branches and staging environments
Once real users depend on the application, stop committing directly to main.
git checkout main
git pull
git checkout -b feature/task-reminders
# ... Claude Code implements and commits ...
git push -u origin feature/task-remindersThen open a pull request on GitHub to review the changes, and merge it into main when validated. Merging to main triggers the production deployment.
A staging environment is a production-like copy used for final testing. Railway supports multiple environments within a project, each with its own services, variables and data. A common setup:
| Environment | Branch | Database | Purpose |
|---|---|---|---|
| Production | main | Production data | Real users |
| Staging | staging or PR branches | Separate test data | Pre-release validation |
Version control and release management
- Write descriptive commit messages: "Add due-date reminders" rather than "updates".
- Tag releases so you can find them later:
git tag -a v1.1.0 -m "Task reminders"
git push origin v1.1.0- Keep a short
CHANGELOG.mddescribing user-visible changes. - Release small changes frequently. Small releases are easier to test and to roll back.
Monitoring and troubleshooting
At minimum:
- Check Railway runtime logs after each deployment and periodically.
- Watch Railway metrics for CPU, memory and network usage trends.
- Make the health check meaningful, but keep it fast.
- Log errors with enough context to diagnose them — never log passwords, tokens or personal data.
- Consider an uptime monitor or error-tracking service as the application grows. Choose one that respects your users' privacy and document what it collects.
When an issue appears, follow the same evidence-first loop: logs → ChatGPT diagnosis → consolidated Claude Code fix → test → deploy.
Database backup practices
- Know what your database service's backup features cover and how far back they go.
- Schedule independent exports for critical data and store them securely.
- Back up immediately before risky migrations.
- Test restores periodically into a non-production database.
- Prefer additive, backward-compatible schema changes.
Security updates
Dependencies receive security fixes regularly. Neglected dependencies are one of the most common sources of vulnerabilities.
npm outdated # see available updates
npm audit # check for known vulnerabilities- Enable Dependabot alerts in your GitHub repository settings.
- Apply patch and minor updates regularly; plan major upgrades as their own sprint.
- After updates, run tests, type checking and the build, then smoke test.
- Rotate secrets when team members leave or a leak is suspected.
- Review who has access to GitHub, Railway and your DNS provider.
Understanding costs
Costs fall into distinct categories. Confusing them is a common and expensive mistake.
| Category | What it is | Who pays | How it scales |
|---|---|---|---|
| AI development subscriptions | ChatGPT and Claude plans used to build the app | You, the builder | Per seat or plan; usage limits apply |
| Application runtime API costs | AI or other APIs your deployed app calls for its users | You, as the operator | Per request or token — grows with users |
| Hosting | Railway compute, memory and network for the app | You | Usage-based |
| Databases | Railway database services and storage | You | Usage and storage-based |
| Domain | Annual registration | You | Fixed per year |
See the Cost Calculator page for an estimation method.
Cost-efficient model selection
If your application calls AI models at runtime:
- Use the smallest, cheapest model that meets quality requirements for each task. Classification and extraction rarely need the largest model.
- Test candidate models on real examples before choosing.
- Limit output length where appropriate.
- Re-evaluate periodically; model options and prices change.
During development, LOW GAS prompts and consolidated sprints reduce subscription usage in the same spirit.
Caching and avoiding duplicate API requests
- Cache results that do not change often, keyed by the input. Redis or a database table can serve as the cache.
- Deduplicate identical concurrent requests.
- Debounce user-triggered calls, such as search-as-you-type.
- Rate limit per user to prevent abuse and runaway costs.
- Store generated results rather than regenerating them on every page load.
Using conventional code for deterministic calculations
If a task has one correct answer that a formula can compute — totals, taxes, dates, sorting, validation, unit conversions — use ordinary code, not an AI model. Conventional code is:
- Free to run at scale.
- Exact and repeatable — the same input always gives the same output.
- Fast and testable.
Reserve AI for tasks that genuinely require language understanding or generation.
Documentation and maintainability
Good documentation keeps both humans and AI agents effective:
- README.md: purpose, setup, commands, environment variables (names only), deployment.
- CLAUDE.md: architecture, conventions and standing rules for Claude Code.
- DEPLOYMENT.md: Railway services, variables, migrations, rollback and recovery steps.
- CHANGELOG.md: what changed in each release.
Ask Claude Code to update these whenever architecture or commands change, as part of the same sprint.
Module 6 checklist
0 of 9 complete