Skip to content
Framework

Project management

upgrade()

Bring a project made by an older Framework up to the current layout.

It prints a plan first and, with dry_run=False, backs up every file it rewrites to .framework/backups/<timestamp>/ (which git ignores) and applies the plan. Your code, data, and notes are not touched. Running it again changes nothing. python -m framework upgrade [--apply] [--no-backup]` (what `fw project upgrade runs) does the same.

The plan covers, in this order:

Usage

upgrade(
    path: str | Path = '.',
    dry_run: bool = True,
    backup: bool = True,
    type: str | None = None,
    move_settings: bool = False,
) -> UpgradeResult

Arguments

Name Type Default Description
path str | Path '.'

The project folder.

dry_run bool True

Print the plan and change nothing.

backup bool True

Copy every file before it is rewritten or removed. Skills replaced by an update are always backed up, to .framework/skills-backups/.

type str | None None

Change the project's type: "project", "project_sensitive", "course", "presentation", or "bare". None (default) keeps it. Making a project project_sensitive sets security: sensitive: true, adds the private and public folders of that layout it lacks (folders it has keep their keys and paths), and then gets the sensitive .gitignore rules, agent guards, and skill like any sensitive project. The plan says where save_table(), save_figure(), save_model(), and save_report() will write from then on (outputs/private/...), and lists the data and render folders that aren't private. A sensitive project made another type stays sensitive.

move_settings bool False

Move top-level keys of the settings file that no environment reads (ehr_source: beside default:) into settings/<key>.yml, keeping their text and comments, and name each file under default: (ehr_source: settings/ehr_source.yml), so settings_read() and settings() read them. False (default) reports them.

Value

An UpgradeResult: the planned actions (step, path, change), notes, whether it was applied, and the backup_location.

Details

  • Settings: a 1.x config.yml becomes settings.yml. Missing sections are added: tools: (Quarto and uv, from the files present) and security:. A project_sensitive project, or one with the private folder layout, gets security: sensitive: true. Keys outside default:, which Framework ignores, are reported, or moved into settings/ with move_settings=True.
  • Connections: the old layouts (options: default_connection: with connections listed flat, or the empty hybrid of both) are rewritten as connections: with default_database, databases, and storage_buckets. A password written into the settings is reported (by key, never by value) and left where it is. The spec refers to it as env("NAME"), NAME being the variable the project already uses for it (in .env, an example .env, or the code), else one made from the connection's name; the plan names it and says to set it.
  • .gitignore: the rules of the current template for the project's type that it lacks, private folders, and folder publishing destinations are appended in one block. No line is removed, and a rule that would ignore files git tracks is left out and reported.
  • AI files: AGENTS.md becomes the canonical context file, with CLAUDE.md a one-line @AGENTS.md pointer, when CLAUDE.md held the full guide; the marked sections are regenerated. A hand-written AGENTS.md is left alone and reported. Sensitive projects get the Claude Code guards (.claude/settings.json) that keep agents out of private folders, whatever the AI settings say: folders with a private (or *_private) segment, folders whose key marks them private (inputs_private_raw: inputs/raw), and private render folders. The plan says when git ignores .claude/, so the guards would stay on one computer.
  • Skills: Framework skills that match a version framework-py has shipped are updated, in the assistants' skills folders and in .agents/skills; missing ones for the type are added, and edited ones are kept and listed. A project with no skills folder gets none, except that a sensitive project gets framework-sensitive-data.
  • Quarto: missing Quarto files are created, and an existing _quarto.yml at most gains missing keys (see quarto_regenerate()).
  • Spec: .framework/spec.json is written from the settings when it is missing, and refreshed when its folders, type, author, security, tools, connections, or copy of .gitignore no longer match, so cloud_register() and fw project push-spec work. It holds only what spec.v1 allows (see spec.v1.json), so keys an earlier upgrade() wrote that Framework Cloud refuses (scaffold.positron, source.upgraded_from) are dropped.

Raises

  • FrameworkError: When the folder is not a Framework project, or is a project in another language.

Search guides and reference for R, Python, Stata, the CLI, and Framework Cloud.