A boss bar is a persistent world object with an id, so the create, set, get and remove commands all have to agree on that id. Build each one here, including the text-component name, and keep the identifier consistent across your command pack.
Loading the workbench…
Every /bossbar subcommand must use the same id. Create with /bossbar add <id> ..., then set value, players and colour with /bossbar set <id> .... A mismatched id silently targets a bar that does not exist.
Set the bar max to your target, then update /bossbar set <id> value <n> from a scoreboard with /execute store result. The editor builds the set command; drive its value from your objective in a repeating function.
/bossbar remove <id> deletes it. Use the same id you created it with; /bossbar list shows every registered bar if you have lost track.